mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-19 13:40:41 -05:00
21 lines
523 B
TypeScript
21 lines
523 B
TypeScript
import * as React from "react";
|
|
import { useFetcher } from "react-router";
|
|
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]);
|
|
}
|