mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-06 05:07:36 -05:00
* Initial * Progress * Fix * Progress * Notifications list page * BADGE_MANAGER_ADDED * Mark as seen initial * Split tables * Progress * Fix styles * Push notifs initial * Progress * Rename * Routines * Progress * Add e2e tests * Done? * Try updating actions * Consistency * Dep fix * A couple fixes
21 lines
527 B
TypeScript
21 lines
527 B
TypeScript
import { useFetcher } from "@remix-run/react";
|
|
import * as React from "react";
|
|
import { NOTIFICATIONS_MARK_AS_SEEN_ROUTE } from "~/utils/urls";
|
|
|
|
export function useMarkNotificationsAsSeen(unseenIds: number[]) {
|
|
const fetcher = useFetcher();
|
|
|
|
React.useEffect(() => {
|
|
if (!unseenIds.length || fetcher.state !== "idle") return;
|
|
|
|
fetcher.submit(
|
|
{ notificationIds: unseenIds },
|
|
{
|
|
method: "post",
|
|
encType: "application/json",
|
|
action: NOTIFICATIONS_MARK_AS_SEEN_ROUTE,
|
|
},
|
|
);
|
|
}, [fetcher, unseenIds]);
|
|
}
|