diff options
author | Hailey <me@haileyok.com> | 2024-05-18 12:23:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-18 12:23:24 -0700 |
commit | 2eaecfcaa49088b8a7172a7f1325506714a4b379 (patch) | |
tree | fdde68227158eadde31d0bb1c43a98771e9cb2b7 /src | |
parent | d2c81c9d3d6aebae9c73a7567875e0165cfb1f08 (diff) | |
download | voidsky-2eaecfcaa49088b8a7172a7f1325506714a4b379.tar.zst |
[🐴] Reset screen when pressing a DM notification while already in the conversation screen (#4091)
* add a small comment * reset if current screen
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/hooks/useNotificationHandler.ts | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts index f3c4da7f6..347062beb 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, @@ -99,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', |