import { atom } from 'jotai'; export type ToastNotif = { id: string; avatarUrl?: string; displayName: string; body: string; roomName: string; roomId: string; hashPath?: string; // overrides window.location.hash navigation when set onClick?: () => void; // custom click handler; skips hash navigation when set sticky?: boolean; // when true, does not auto-dismiss — use for action toasts that require a click }; const baseAtom = atom([]); // Write-only setter used in ClientNonUIFeatures export const toastQueueAtom = atom( (get) => get(baseAtom), (get, set, notif) => { if (notif === null) return; // no-op guard set(baseAtom, [...get(baseAtom), notif]); }, ); export const dismissToastAtom = atom(null, (get, set, id) => set( baseAtom, get(baseAtom).filter((t) => t.id !== id), ), );