Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apps/pano): show "Duzenle" and "Sil" on more options for the post #629

Merged
merged 8 commits into from
Aug 13, 2023
Merged
21 changes: 19 additions & 2 deletions apps/kampus/app/pano/PanoFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Suspense, useCallback } from "react";
import { graphql, usePaginationFragment } from "react-relay";
import { graphql, useFragment, usePaginationFragment } from "react-relay";

import { Button } from "@kampus/ui-next";

import { PostItem } from "~/app/pano/features/post-list/PostItem";
import { type PanoFeed_viewer$key } from "./__generated__/PanoFeed_viewer.graphql";
import { type PanoFeedFragment$key } from "./__generated__/PanoFeedFragment.graphql";

const fragment = graphql`
Expand All @@ -17,6 +18,7 @@ const fragment = graphql`
@refetchable(queryName: "PanoFeedPaginationQuery") {
panoFeed(first: $first, after: $after, last: $last, before: $before)
@connection(key: "PanoFeedFragment__panoFeed") {
__id
edges {
cursor
node {
Expand All @@ -28,15 +30,23 @@ const fragment = graphql`
}
`;

const viewerFragment = graphql`
fragment PanoFeed_viewer on Viewer {
...PostItem_viewer
}
`;

interface Props {
panoFeed: PanoFeedFragment$key;
panoViewer: PanoFeed_viewer$key;
}

export function PanoFeed(props: Props) {
const { data, hasNext, hasPrevious, loadNext, loadPrevious } = usePaginationFragment(
fragment,
props.panoFeed
);
const viewer = useFragment(viewerFragment, props.panoViewer);

const feed = data.panoFeed;

Expand All @@ -60,7 +70,14 @@ export function PanoFeed(props: Props) {
return null;
}

return <PostItem key={edge.node.id} post={edge.node} />;
return (
<PostItem
key={edge.node.id}
post={edge.node}
viewerRef={viewer}
postConnectionId={data.panoFeed?.__id}
/>
);
})}

<div className="flex gap-2">
Expand Down
3 changes: 2 additions & 1 deletion apps/kampus/app/pano/PostListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const query = graphql`
query PostListContainerQuery {
viewer {
...PanoFeedFragment
...PanoFeed_viewer
}
}
`;
Expand All @@ -28,5 +29,5 @@ export const PostListContainer = (props: Props) => {
return null;
}

return <PanoFeed panoFeed={data.viewer} />;
return <PanoFeed panoFeed={data.viewer} panoViewer={data.viewer} />;
};
17 changes: 15 additions & 2 deletions apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading