feat: page update notifications (#2074)

* feat: watchers notification and email preferences

* fix: email copy

* digests

* clean up

* fix

* clean up

* move backlinks queue-up to history processor

* fix

* fix keys

* feat: group notifications

* filter

* adjust email digest window
This commit is contained in:
Philip Okugbe
2026-03-31 16:03:59 +01:00
committed by GitHub
parent c180d0e487
commit 879aa2c3d8
39 changed files with 983 additions and 73 deletions
@@ -0,0 +1,43 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
watchPage,
unwatchPage,
getWatchStatus,
} from "@/features/page/services/watcher-service";
import { notifications } from "@mantine/notifications";
import { useTranslation } from "react-i18next";
const WATCHER_KEY = "watcher";
export function useWatchStatusQuery(pageId: string) {
return useQuery({
queryKey: [WATCHER_KEY, pageId],
queryFn: () => getWatchStatus(pageId),
enabled: !!pageId,
staleTime: 60_000,
});
}
export function useWatchPageMutation() {
const queryClient = useQueryClient();
const { t } = useTranslation();
return useMutation({
mutationFn: (pageId: string) => watchPage(pageId),
onSuccess: (_data, pageId) => {
queryClient.setQueryData([WATCHER_KEY, pageId], { watching: true });
notifications.show({ message: t("You are now watching this page") });
},
});
}
export function useUnwatchPageMutation() {
const queryClient = useQueryClient();
const { t } = useTranslation();
return useMutation({
mutationFn: (pageId: string) => unwatchPage(pageId),
onSuccess: (_data, pageId) => {
queryClient.setQueryData([WATCHER_KEY, pageId], { watching: false });
notifications.show({ message: t("You are no longer watching this page") });
},
});
}