Files
cozsweet-frontend-nextjs/src/providers/chat-action-arrival-tracker.tsx
T

29 lines
685 B
TypeScript

"use client";
import { useEffect } from "react";
import { usePathname } from "next/navigation";
import {
clearPendingChatActionArrival,
readPendingChatActionArrival,
recordChatActionEventById,
} from "@/lib/chat/chat_action_events";
export function ChatActionArrivalTracker() {
const pathname = usePathname();
useEffect(() => {
const pending = readPendingChatActionArrival();
if (!pending || pathname !== pending.expectedPath) return;
void recordChatActionEventById(
pending.actionId,
pending.characterId,
"arrived",
)
.then(() => clearPendingChatActionArrival())
.catch(() => undefined);
}, [pathname]);
return null;
}