Skip to content

Commit

Permalink
feat(apps/pano): use relay in post more options
Browse files Browse the repository at this point in the history
  • Loading branch information
cansirin committed Aug 12, 2023
1 parent b7064b4 commit 242ed61
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 74 deletions.
12 changes: 11 additions & 1 deletion 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 { PanoFeed_viewer$key } from "./__generated__/PanoFeed_viewer.graphql";
import { type PanoFeedFragment$key } from "./__generated__/PanoFeedFragment.graphql";

const fragment = graphql`
Expand All @@ -28,15 +29,24 @@ const fragment = graphql`
}
`;

const viewerFragment = graphql`
fragment PanoFeed_viewer on Actor {
displayName
}
`;

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

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

const feed = data.panoFeed;

Expand Down
6 changes: 5 additions & 1 deletion apps/kampus/app/pano/PostListContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ const query = graphql`
query PostListContainerQuery {
viewer {
...PanoFeedFragment
actor {
...PanoFeed_viewer
}
}
}
`;

export const PostListContainer = (props: Props) => {
const queryRef = useSerializablePreloadedQuery(props.preloadedQuery);
const data = usePreloadedQuery(query, queryRef);
console.log(data);

if (!data.viewer) {
return null;
}

return <PanoFeed panoFeed={data.viewer} />;
return <PanoFeed panoFeed={data.viewer} panoViewer={data.viewer.actor} />;
};

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

42 changes: 42 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

0 comments on commit 242ed61

Please sign in to comment.