From 092335ee435686b7ee621b1d59206cc8fa2dfbec Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 02:31:23 -0700 Subject: [PATCH] fix: guard notification sound async state (#3574) --- src/renderer/src/components/settings/NotificationsPane.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/settings/NotificationsPane.tsx b/src/renderer/src/components/settings/NotificationsPane.tsx index 6c87aabe217..1e9330074e1 100644 --- a/src/renderer/src/components/settings/NotificationsPane.tsx +++ b/src/renderer/src/components/settings/NotificationsPane.tsx @@ -16,6 +16,7 @@ import { } from '../ui/select' import { BellRing, Bot, FileAudio, Siren, Upload, Volume2 } from 'lucide-react' import { getNotificationSoundOptions } from '@/components/notification-sound-options' +import { useMountedRef } from '@/hooks/useMountedRef' import { useAppStore } from '@/store' export { NOTIFICATIONS_PANE_SEARCH_ENTRIES } from './notifications-search' @@ -142,6 +143,7 @@ export function NotificationsPane({ }: NotificationsPaneProps): React.JSX.Element { const notificationSettings = settings.notifications const notificationSettingsRef = useRef(notificationSettings) + const mountedRef = useMountedRef() const [isPickingSound, setIsPickingSound] = useState(false) const updateNotificationSettings = async ( @@ -203,7 +205,9 @@ export function NotificationsPane({ await previewSound('custom') } } finally { - setIsPickingSound(false) + if (mountedRef.current) { + setIsPickingSound(false) + } } }