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

Function useDeleteComment

packages/shared/src/hooks/comments/useDeleteComment.ts:35–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33};
34
35export function useDeleteComment(): UseDeleteCommentRet {
36 const client = useQueryClient();
37 const { showPrompt } = usePrompt();
38 const { logEvent } = useLogContext();
39 const { displayToast } = useToastNotification();
40 const { requestMethod } = useRequestProtocol();
41
42 return {
43 deleteComment: useCallback(
44 async (commentId, parentId, post) => {
45 if (!(await showPrompt(options))) {
46 return;
47 }
48
49 logEvent(postLogEvent(LogEvent.DeleteComment, post));
50 await deleteComment(commentId, requestMethod);
51 displayToast('The comment has been deleted');
52 // Callers pass `null` for root comments; `removePostComments` treats
53 // `parentId === commentId` as the root case, matching the convention
54 // used in MainComment (`parentId={comment.id}`).
55 removePostComments(client, post, commentId, parentId ?? commentId);
56 },
57 [client, showPrompt, logEvent, displayToast, requestMethod],
58 ),
59 };
60}

Callers 3

CommentFeedFunction · 0.90
PostCommentsFunction · 0.90
ActivityRepliesTabFunction · 0.90

Calls 9

usePromptFunction · 0.90
useLogContextFunction · 0.90
useToastNotificationFunction · 0.90
useRequestProtocolFunction · 0.90
postLogEventFunction · 0.90
deleteCommentFunction · 0.90
removePostCommentsFunction · 0.90
logEventFunction · 0.85
displayToastFunction · 0.85

Tested by

no test coverage detected