import { useSyncExternalStore } from 'react'; import { getDeleteProgressSnapshot, subscribeDeleteProgress } from '../../lib/delete-progress'; /** * Global "deletion in progress" indicator. * * Mounted once at the app root, outside every tab panel, so it shows no matter * which view started the delete — per-tab copies were hidden along with their * `hidden` tab panel, and detail views had no indicator at all. State comes * from the delete-progress store rather than props so it also survives the * initiating component unmounting mid-request. * * Renders two signals: a sweeping bar pinned to the top edge (visible even when * the eye is on the content being deleted) and a bottom-right toast naming the * work. */ export function DeleteProgressToast() { const { count, label } = useSyncExternalStore( subscribeDeleteProgress, getDeleteProgressSnapshot, getDeleteProgressSnapshot, ); if (count <= 0) return null; const message = count > 1 ? `Deleting ${count} items` : (label ?? 'Deleting'); return ( <>