MCPcopy Create free account
hub / github.com/dailydotdev/apps / CommentFeed

Function CommentFeed

packages/shared/src/components/CommentFeed.tsx:30–121  ·  view source on GitHub ↗
({
  feedQueryKey,
  query,
  logOrigin,
  variables,
  emptyScreen,
  commentClassName,
  isMainFeed,
}: CommentFeedProps<T>)

Source from the content-addressed store, hash-verified

28}
29
30export default function CommentFeed<T>({
31 feedQueryKey,
32 query,
33 logOrigin,
34 variables,
35 emptyScreen,
36 commentClassName,
37 isMainFeed,
38}: CommentFeedProps<T>): ReactElement {
39 const { openShareComment } = useShareComment(logOrigin);
40 const { onShowUpvoted } = useUpvoteQuery();
41 const { deleteComment } = useDeleteComment();
42 const isLaptop = useViewSize(ViewSize.Laptop);
43
44 const queryResult = useInfiniteQuery<CommentFeedData>({
45 queryKey: feedQueryKey,
46 queryFn: ({ pageParam }) =>
47 gqlClient.request(query, {
48 ...variables,
49 first: 20,
50 after: pageParam,
51 }),
52 initialPageParam: '',
53 getNextPageParam: ({ page }) => getNextPageParam(page?.pageInfo),
54 });
55 const length = queryResult?.data?.pages?.length;
56 const showEmptyScreen =
57 length > 0 && queryResult.data.pages[0].page.edges.length === 0;
58
59 if (queryResult.isPending) {
60 return (
61 <PlaceholderCommentList
62 placeholderAmount={5}
63 className={classNames(
64 '!mt-0 border-border-subtlest-tertiary p-4',
65 commentClassName?.container,
66 )}
67 showContextHeader
68 />
69 );
70 }
71
72 if (showEmptyScreen && emptyScreen) {
73 return <>{emptyScreen}</>;
74 }
75
76 return (
77 <>
78 <InfiniteScrolling
79 isFetchingNextPage={queryResult.isFetchingNextPage}
80 canFetchMore={checkFetchMore(queryResult)}
81 fetchNextPage={queryResult.fetchNextPage}
82 className="w-full"
83 >
84 {queryResult.data.pages.flatMap((page) =>
85 page.page.edges.map(({ node }, index) => (
86 <MainComment
87 key={node.id}

Callers

nothing calls this directly

Calls 8

useShareCommentFunction · 0.90
useUpvoteQueryFunction · 0.90
useDeleteCommentFunction · 0.90
useViewSizeFunction · 0.90
getNextPageParamFunction · 0.90
checkFetchMoreFunction · 0.90
deleteCommentFunction · 0.85
onShowUpvotedFunction · 0.85

Tested by

no test coverage detected