import React from 'react'; import { useAtomValue, useSetAtom } from 'jotai'; import { Box, Button, Text, IconButton, Icon, Icons, IconSrc, Scroll, config, toRem } from 'folds'; import { Page, PageContent, PageHeader } from '../../../components/page'; import { SystemNotification } from './SystemNotification'; import { AllMessagesNotifications } from './AllMessages'; import { SpecialMessagesNotifications } from './SpecialMessages'; import { KeywordMessagesNotifications } from './KeywordMessages'; import { PushRuleEditor } from './PushRuleEditor'; 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; // 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', icon: Icons.Ball, description: 'Notifications on, sounds off', patch: { showNotifications: true, isNotificationSounds: false, messageSoundId: 'none', inviteSoundId: 'none', quietHoursEnabled: false, }, clearSnooze: true, }, { label: 'Work', icon: Icons.Monitor, description: 'All notifications and sounds on', patch: { showNotifications: true, isNotificationSounds: true, messageSoundId: 'notification', inviteSoundId: 'invite', quietHoursEnabled: false, }, clearSnooze: true, }, { label: 'Sleep', icon: Icons.BellMute, description: 'All notifications off', patch: { showNotifications: false, isNotificationSounds: false, quietHoursEnabled: false, }, clearSnooze: false, }, ]; function NotificationPresets() { const settings = useAtomValue(settingsAtom); const setSettings = useSetAtom(settingsAtom); const setSnoozeUntil = useSetAtom(notificationSnoozeUntilAtom); const applyPreset = (patch: Partial, 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 ( Quick Presets {PRESETS.map((preset) => ( ))} ); } type NotificationsProps = { requestClose: () => void; }; export function Notifications({ requestClose }: NotificationsProps) { return ( Notifications Block Messages ); }