(queryKey: QueryKey, id: string)
| 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); |
no test coverage detected