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

Function optimisticPostUpdateInFeed

packages/shared/src/lib/feed.ts:15–29  ·  view source on GitHub ↗
(
  items: FeedItem[],
  updatePost: (page: number, index: number, post: Post) => void,
  mutationFunction: (post: Post) => Partial<Post>,
)

Source from the content-addressed store, hash-verified

13import { useFeedCardContext } from '../features/posts/FeedCardContext';
14
15export function optimisticPostUpdateInFeed(
16 items: FeedItem[],
17 updatePost: (page: number, index: number, post: Post) => void,
18 mutationFunction: (post: Post) => Partial<Post>,
19): ({ index }: { index: number }) => Promise<() => void> {
20 return async ({ index }) => {
21 const item = items[index] as PostItem;
22 const { post } = item;
23 updatePost(item.page, item.index, {
24 ...post,
25 ...mutationFunction(post),
26 });
27 return () => updatePost(item.page, item.index, post);
28 };
29}
30
31interface FeedItemLogEvent extends LogEvent {
32 event_name: string;

Callers 5

mutateBookmarkFeedPostFunction · 0.90
useOnPostClickFunction · 0.90
usePostFeedbackFunction · 0.90
patchBookmarkInCachesFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

updatePostFunction · 0.50

Tested by

no test coverage detected