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

Function useFeedOnPostClick

packages/shared/src/hooks/feed/useFeedOnPostClick.ts:33–74  ·  view source on GitHub ↗
({
  items,
  updatePost,
  columns,
  feedName,
  ranking,
  eventName = 'click',
  feedQueryKey,
  searchLogExtra,
}: UseFeedOnPostClickProps)

Source from the content-addressed store, hash-verified

31}
32
33export default function useFeedOnPostClick({
34 items,
35 updatePost,
36 columns,
37 feedName,
38 ranking,
39 eventName = 'click',
40 feedQueryKey,
41 searchLogExtra,
42}: UseFeedOnPostClickProps): FeedPostClick {
43 const queryClient = useQueryClient();
44 const onPostClick = useOnPostClick({
45 eventName,
46 columns,
47 feedName,
48 ranking,
49 searchLogExtra,
50 });
51
52 return useMemo(
53 () =>
54 async (post, index, row, column, optional): Promise<void> => {
55 await onPostClick({ post, row, column, index, optional });
56
57 if (optional?.skipPostUpdate) {
58 return;
59 }
60
61 const item = items[index];
62 if (item.type === 'post') {
63 updatePost(item.page, item.index, { ...post, read: true });
64 } else if (isBoostedPostAd(item) && feedQueryKey) {
65 updateFeedAndAdsCache(post.id, feedQueryKey, queryClient, {
66 read: true,
67 });
68 }
69 },
70 // @NOTE see https://dailydotdev.atlassian.net/l/cp/dK9h1zoM
71 // eslint-disable-next-line react-hooks/exhaustive-deps
72 [items, updatePost, columns, feedName, ranking, searchLogExtra],
73 );
74}

Callers 1

FeedFunction · 0.85

Calls 4

isBoostedPostAdFunction · 0.90
updateFeedAndAdsCacheFunction · 0.90
useOnPostClickFunction · 0.85
updatePostFunction · 0.50

Tested by

no test coverage detected