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

Function useReadingHistory

packages/shared/src/hooks/useReadingHistory.ts:101–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99 }));
100
101function useReadingHistory(): UseReadingHistoryReturn {
102 const client = useQueryClient();
103 const { user } = useAuthContext();
104 const { mutateAsync } = useMutation<
105 unknown,
106 unknown,
107 HidePostItemCardProps,
108 () => void
109 >({
110 mutationFn: ({ postId, timestamp }: HidePostItemCardProps) =>
111 gqlClient.request(HIDE_READING_HISTORY_MUTATION, {
112 postId,
113 timestamp,
114 }),
115 onMutate: (params) => removeReadingHistoryEntry(client, user, params),
116 onError: (_, __, rollback) => rollback?.(),
117 });
118
119 const hideReadHistory = useCallback<HideReadHistory>(
120 (params) => mutateAsync(params),
121 [mutateAsync],
122 );
123
124 return { hideReadHistory };
125}
126
127export default useReadingHistory;

Callers 1

ReadingHistoryFunction · 0.85

Calls 3

useAuthContextFunction · 0.90
rollbackFunction · 0.85

Tested by

no test coverage detected