From 4642b73d9cb63821a706459e0de1030d80a7b196 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sat, 18 May 2024 01:39:09 -0700 Subject: [PATCH 1/2] add a small comment --- src/lib/hooks/useNotificationHandler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts index f3c4da7f63..d31e9768e5 100644 --- a/src/lib/hooks/useNotificationHandler.ts +++ b/src/lib/hooks/useNotificationHandler.ts @@ -59,9 +59,13 @@ export function useNotificationsHandler() { const {setShowLoggedOut} = useLoggedOutViewControls() const closeAllActiveElements = useCloseAllActiveElements() + // On Android, we cannot control which sound is used for a notification on Android + // 28 or higher. Instead, we have to configure a notification channel ahead of time + // which has the sounds we want in the configuration for that channel. These two + // channels allow for the mute/unmute functionality we want for the background + // handler. React.useEffect(() => { if (!isAndroid) return - Notifications.setNotificationChannelAsync('chat-messages', { name: 'Chat', importance: Notifications.AndroidImportance.MAX, From 60b253993bfc91e30f7f38a039e9d37711491ff8 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sat, 18 May 2024 01:45:36 -0700 Subject: [PATCH 2/2] reset if current screen --- src/lib/hooks/useNotificationHandler.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts index d31e9768e5..347062bebe 100644 --- a/src/lib/hooks/useNotificationHandler.ts +++ b/src/lib/hooks/useNotificationHandler.ts @@ -103,9 +103,27 @@ export function useNotificationsHandler() { } else { navigation.dispatch(state => { if (state.routes[0].name === 'Messages') { - return CommonActions.navigate('MessagesConversation', { - conversation: payload.convoId, - }) + if ( + state.routes[state.routes.length - 1].name === + 'MessagesConversation' + ) { + return CommonActions.reset({ + ...state, + routes: [ + ...state.routes.slice(0, state.routes.length - 1), + { + name: 'MessagesConversation', + params: { + conversation: payload.convoId, + }, + }, + ], + }) + } else { + return CommonActions.navigate('MessagesConversation', { + conversation: payload.convoId, + }) + } } else { return CommonActions.navigate('MessagesTab', { screen: 'Messages',