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

Function optimisticPostUpdateInFeed

packages/shared/src/lib/feed.ts:13–27  ·  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

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

Callers 5

mutateBookmarkFeedPostFunction · 0.90
useOnPostClickFunction · 0.90
usePostFeedbackFunction · 0.90
onUpdateCacheFunction · 0.90
mutateVoteFeedPostFunction · 0.90

Calls 1

updatePostFunction · 0.50

Tested by

no test coverage detected