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

Function trySetPostRead

packages/shared/src/hooks/useOnPostClick.ts:182–207  ·  view source on GitHub ↗
(queryKey: QueryKey, id: string)

Source from the content-addressed store, hash-verified

180 }
181 } else if (!feedName && shouldUseListFeedLayout) {
182 const trySetPostRead = (queryKey: QueryKey, id: string) => {
183 const updateFeedPost = updateCachedPagePost(
184 queryKey as unknown[],
185 client,
186 );
187
188 const data =
189 client.getQueryData<InfiniteData<FeedData>>(queryKey);
190 // A feed in the cache that never loaded (or failed) has no
191 // pages to look the post up in.
192 if (!data?.pages) {
193 return;
194 }
195
196 const {
197 post: foundPost,
198 page,
199 index: foundIndex,
200 } = findPost(data, id);
201 if (foundPost) {
202 updateFeedPost(page, foundIndex, {
203 ...foundPost,
204 ...mutationHandler(foundPost),
205 });
206 }
207 };
208
209 getFeedQueryKeys(client).forEach((key) => {
210 trySetPostRead(key, post.id);

Callers 1

useOnPostClickFunction · 0.85

Calls 3

updateCachedPagePostFunction · 0.90
findPostFunction · 0.85
mutationHandlerFunction · 0.70

Tested by

no test coverage detected