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:
@@ -11,12 +11,19 @@ import { SequenceCard } from '../../../components/sequence-card';
|
|||||||
import { SequenceCardStyle } from '../styles.css';
|
import { SequenceCardStyle } from '../styles.css';
|
||||||
import { SettingTile } from '../../../components/setting-tile';
|
import { SettingTile } from '../../../components/setting-tile';
|
||||||
import { settingsAtom, Settings } from '../../../state/settings';
|
import { settingsAtom, Settings } from '../../../state/settings';
|
||||||
|
import { notificationSnoozeUntilAtom } from '../../../state/notificationSnooze';
|
||||||
|
|
||||||
const PRESETS: Array<{
|
const PRESETS: Array<{
|
||||||
label: string;
|
label: string;
|
||||||
icon: IconSrc;
|
icon: IconSrc;
|
||||||
description: string;
|
description: string;
|
||||||
patch: Partial<Settings>;
|
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',
|
label: 'Gaming',
|
||||||
@@ -29,6 +36,7 @@ const PRESETS: Array<{
|
|||||||
inviteSoundId: 'none',
|
inviteSoundId: 'none',
|
||||||
quietHoursEnabled: false,
|
quietHoursEnabled: false,
|
||||||
},
|
},
|
||||||
|
clearSnooze: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Work',
|
label: 'Work',
|
||||||
@@ -41,6 +49,7 @@ const PRESETS: Array<{
|
|||||||
inviteSoundId: 'invite',
|
inviteSoundId: 'invite',
|
||||||
quietHoursEnabled: false,
|
quietHoursEnabled: false,
|
||||||
},
|
},
|
||||||
|
clearSnooze: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Sleep',
|
label: 'Sleep',
|
||||||
@@ -51,15 +60,23 @@ const PRESETS: Array<{
|
|||||||
isNotificationSounds: false,
|
isNotificationSounds: false,
|
||||||
quietHoursEnabled: false,
|
quietHoursEnabled: false,
|
||||||
},
|
},
|
||||||
|
clearSnooze: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function NotificationPresets() {
|
function NotificationPresets() {
|
||||||
const settings = useAtomValue(settingsAtom);
|
const settings = useAtomValue(settingsAtom);
|
||||||
const setSettings = useSetAtom(settingsAtom);
|
const setSettings = useSetAtom(settingsAtom);
|
||||||
|
const setSnoozeUntil = useSetAtom(notificationSnoozeUntilAtom);
|
||||||
|
|
||||||
const applyPreset = (patch: Partial<Settings>) => {
|
const applyPreset = (patch: Partial<Settings>, clearSnooze: boolean) => {
|
||||||
setSettings({ ...settings, ...patch });
|
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 (
|
return (
|
||||||
@@ -71,7 +88,7 @@ function NotificationPresets() {
|
|||||||
<Button
|
<Button
|
||||||
key={preset.label}
|
key={preset.label}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => applyPreset(preset.patch)}
|
onClick={() => applyPreset(preset.patch, preset.clearSnooze)}
|
||||||
title={preset.description}
|
title={preset.description}
|
||||||
variant="Secondary"
|
variant="Secondary"
|
||||||
fill="Soft"
|
fill="Soft"
|
||||||
|
|||||||
Reference in New Issue
Block a user