Files
cinny/src/app/state/notificationSnooze.ts
T

23 lines
864 B
TypeScript
Raw Normal View History

import { atomWithStorage, createJSONStorage } from 'jotai/utils';
/**
* Cross-platform "pause notifications" / snooze.
*
* Unlike `manualDndAtom` (which only mirrors the desktop tray toggle and is
* session-only), this is a user-set snooze that works on web/mobile/desktop and
* survives a reload. The value is the epoch-ms instant until which notifications
* are paused; `0` means not snoozed. `SNOOZE_INDEFINITE` represents "paused until
* I turn it back on".
*
* The pure helpers live in `utils/snooze.ts` (unit-tested); re-exported here so
* consumers have a single import site.
*/
export { SNOOZE_INDEFINITE, isSnoozeActive, nextTimeAtHour } from '../utils/snooze';
export const notificationSnoozeUntilAtom = atomWithStorage<number>(
'cinny_notification_snooze_until_v1',
0,
createJSONStorage(() => localStorage),
{ getOnInit: true },
);