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

Function updatePost

packages/shared/src/hooks/useUpdatePost.ts:15–36  ·  view source on GitHub ↗
(props: UpdateData)

Source from the content-addressed store, hash-verified

13
14 const updatePost =
15 (props: UpdateData): MutateFunc<UpdateData> =>
16 async () => {
17 const postQueryKey = getPostByIdKey(props.id);
18 await client.cancelQueries({ queryKey: postQueryKey });
19 const oldPost = client.getQueryData<PostData>(postQueryKey);
20
21 if (!oldPost) {
22 // nothing in cache so we skip any update
23
24 return () => undefined;
25 }
26
27 client.setQueryData<PostData>(postQueryKey, {
28 post: {
29 ...oldPost.post,
30 ...props.update,
31 },
32 });
33 return () => {
34 client.setQueryData<PostData>(postQueryKey, oldPost);
35 };
36 };
37
38 return {
39 updatePost,

Callers 10

usePostModalNavigationFunction · 0.70
useFeedFunction · 0.70
FeedFunction · 0.50
createVoteOnMutateFunction · 0.50
createBookmarkOnMutateFunction · 0.50
usePostToSquadFunction · 0.50
useTranslationFunction · 0.50
useFeedOnPostClickFunction · 0.50

Calls 1

getPostByIdKeyFunction · 0.90

Tested by

no test coverage detected