React context module that manages notification state for the OpenFrame notifications system, providing CRUD operations, read/settled tracking, drawer open/close control, and optional server-side persistence callbacks. ## Key Components ### `NotificationsProvider` Top-level provider that initializes state via `useReducer` and exposes all notification operations through context. Accepts pagination props (`hasMore`, `isLoadingMore`, `onLoadMore`), popup visibility controls, desktop OS notification opt-in, and a custom tile renderer override. ### `NotificationsActions` Optional server-side callback hooks — `onMarkRead`, `onMarkAllRead`, `onRemove`, `onMarkSettled` — fired after local state updates for persistence sync. ### Internal `reducer` Handles `add`, `upsert`, `set`, `markRead`, `markAllRead`, `markSettled`, `remove`, and `clear` actions. The `upsert` action preserves position on update; `add` prepends and promotes to top. Both respect `maxNotifications`. ### `useNotifications` Strict hook — throws if called outside ``. ### `useOptionalNotifications` Soft hook — returns `null` when no provider is present, safe for optional integration. ## Usage Example ```typescript import { NotificationsProvider, useNotifications, } from './notifications-context' // Wrap your app or feature subtree function App() { return ( fetchMoreNotifications()} actions={{ onMarkRead: async (id) => await api.markRead(id), onRemove: async (id) => await api.deleteNotification(id), }} > ) } // Consume in any child component function NotificationsBell() { const { unreadCount, addNotification, markAllRead, toggle } = useNotifications() return ( ) } ``` ## Notes - `upsert` vs `add`: `add` promotes the item to the top of the list on collision; `upsert` updates in place. - `actionsRef` pattern prevents stale closures when persistence callbacks change between renders. - `desktopPopupsConfigured` is `true` only when `onShowDesktopPopupsChange` is provided, gating the OS-level toggle in the UI. **Source:** [`notifications-context.tsx`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/notifications-context.tsx)