fix(notifications): Work/Gaming presets clear an active snooze

Both presets claim notifications end up on, but left a "Pause
Notifications" snooze in place. Sleep is unchanged (its description
holds regardless).

Fixes #48

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
2026-09-12 19:46:06 -04:00
co-authored by Claude Opus 5
parent 6b9c8de393
commit fb14db6d50
@@ -11,12 +11,19 @@ import { SequenceCard } from '../../../components/sequence-card';
import { SequenceCardStyle } from '../styles.css';
import { SettingTile } from '../../../components/setting-tile';
import { settingsAtom, Settings } from '../../../state/settings';
import { notificationSnoozeUntilAtom } from '../../../state/notificationSnooze';
const PRESETS: Array<{
label: string;
icon: IconSrc;
description: string;
patch: Partial<Settings>;
// Whether applying this preset should also clear an active "Pause
// Notifications" snooze. Work/Gaming both claim notifications end up on,
// so a leftover snooze would silently contradict them (#48). Sleep's
// description ("All notifications off") is still true with a snooze left
// active, so it does not need to touch it.
clearSnooze: boolean;
}> = [
{
label: 'Gaming',
@@ -29,6 +36,7 @@ const PRESETS: Array<{
inviteSoundId: 'none',
quietHoursEnabled: false,
},
clearSnooze: true,
},
{
label: 'Work',
@@ -41,6 +49,7 @@ const PRESETS: Array<{
inviteSoundId: 'invite',
quietHoursEnabled: false,
},
clearSnooze: true,
},
{
label: 'Sleep',
@@ -51,15 +60,23 @@ const PRESETS: Array<{
isNotificationSounds: false,
quietHoursEnabled: false,
},
clearSnooze: false,
},
];
function NotificationPresets() {
const settings = useAtomValue(settingsAtom);
const setSettings = useSetAtom(settingsAtom);
const setSnoozeUntil = useSetAtom(notificationSnoozeUntilAtom);
const applyPreset = (patch: Partial<Settings>) => {
const applyPreset = (patch: Partial<Settings>, clearSnooze: boolean) => {
setSettings({ ...settings, ...patch });
// Work/Gaming promise notifications are on; an active snooze from an
// earlier "Pause Notifications" would otherwise keep them silently
// suppressed despite the preset applying successfully (#48).
if (clearSnooze) {
setSnoozeUntil(0);
}
};
return (
@@ -71,7 +88,7 @@ function NotificationPresets() {
<Button
key={preset.label}
type="button"
onClick={() => applyPreset(preset.patch)}
onClick={() => applyPreset(preset.patch, preset.clearSnooze)}
title={preset.description}
variant="Secondary"
fill="Soft"