import { cn } from '~web/utils/helpers'; import { NotificationEvent, useNotificationsContext } from './data'; import { Popover } from './popover'; import { VolumeOffIcon, VolumeOnIcon } from './icons'; import { playNotificationSound } from '~core/utils'; export const NotificationTabs = ({ selectedEvent: _, }: { selectedEvent: NotificationEvent; }) => { const { notificationState, setNotificationState, setRoute } = useNotificationsContext(); return (
{ setNotificationState((prev) => { if ( prev.audioNotificationsOptions.enabled && prev.audioNotificationsOptions.audioContext.state !== 'closed' ) { prev.audioNotificationsOptions.audioContext.close(); } const prevEnabledState = prev.audioNotificationsOptions.enabled; localStorage.setItem( 'react-scan-notifications-audio', String(!prevEnabledState), ); const audioContext = new AudioContext(); if (!prev.audioNotificationsOptions.enabled) { playNotificationSound(audioContext); } if (prevEnabledState) { audioContext.close(); } return { ...prev, audioNotificationsOptions: prevEnabledState ? { audioContext: null, enabled: false, } : { audioContext, enabled: true, }, }; }); }} className="ml-auto" >
Alerts {notificationState.audioNotificationsOptions.enabled ? ( ) : ( )}
} > <>Play a chime when a slowdown is recorded
); };