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

Function optimisticPostUpdateInFeed

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

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