feat(notifications): cross-platform "Pause Notifications" / snooze
Manual DND only existed via the desktop tray (manualDndAtom), so web/mobile users had no way to pause notifications, and there was no snooze-for-a-duration anywhere. Add a "Pause Notifications" control in Settings > Notifications: - Presets: 30 min / 1 hour / 4 hours / Until 8 AM / Until I resume, plus Resume; live "Paused until ..." status that flips back on when the snooze lapses. - Persisted snooze instant (cinny_notification_snooze_until_v1) so it survives a reload; 0 = off, SNOOZE_INDEFINITE = until resumed. - Feeds the existing notification gate (ClientNonUIFeatures, both the message and invite monitors) alongside Focus Assist / manual DND / Quiet Hours, suppressing notify() and playSound(). - Pure helpers isSnoozeActive/nextTimeAtHour/SNOOZE_INDEFINITE in utils/snooze.ts (+5 unit tests); persisted atom in state/notificationSnooze.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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 },
|
||||
);
|
||||
Reference in New Issue
Block a user