From e1c74124e280f56c82ee85e21dbc40f77ef1beab Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 11 Oct 2022 10:36:45 -0300 Subject: [PATCH] Fix switch to channel when notification is dismissed (#6675) --- app/constants/screens.ts | 6 ++++++ app/init/push_notifications.ts | 1 - app/screens/navigation.ts | 5 +---- index.ts | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/constants/screens.ts b/app/constants/screens.ts index 63cf605f7a..ddef79467d 100644 --- a/app/constants/screens.ts +++ b/app/constants/screens.ts @@ -149,6 +149,12 @@ export const SCREENS_WITH_TRANSPARENT_BACKGROUND = new Set([ USER_PROFILE, ]); +export const OVERLAY_SCREENS = new Set([ + IN_APP_NOTIFICATION, + GALLERY, + SNACK_BAR, +]); + export const NOT_READY = [ CHANNEL_ADD_PEOPLE, CHANNEL_MENTION, diff --git a/app/init/push_notifications.ts b/app/init/push_notifications.ts index b555f44267..01cfeee203 100644 --- a/app/init/push_notifications.ts +++ b/app/init/push_notifications.ts @@ -113,7 +113,6 @@ class PushNotifications { const screen = Screens.IN_APP_NOTIFICATION; const passProps = { notification, - overlay: true, serverName, serverUrl, }; diff --git a/app/screens/navigation.ts b/app/screens/navigation.ts index dd6bb72e42..dfe018412f 100644 --- a/app/screens/navigation.ts +++ b/app/screens/navigation.ts @@ -615,10 +615,7 @@ export function showOverlay(name: string, passProps = {}, options = {}) { component: { id: name, name, - passProps: { - ...passProps, - overlay: true, - }, + passProps, options: merge(defaultOptions, options), }, }); diff --git a/index.ts b/index.ts index 9fcf68eec2..230e15b604 100644 --- a/index.ts +++ b/index.ts @@ -8,6 +8,7 @@ import 'react-native-gesture-handler'; import {ComponentDidAppearEvent, ComponentDidDisappearEvent, ModalDismissedEvent, Navigation, ScreenPoppedEvent} from 'react-native-navigation'; import {Events, Screens} from './app/constants'; +import {OVERLAY_SCREENS} from './app/constants/screens'; import DatabaseManager from './app/database/manager'; import {getAllServerCredentials} from './app/init/credentials'; import {initialLaunch} from './app/init/launch'; @@ -98,8 +99,8 @@ function screenWillAppear({componentId}: ComponentDidAppearEvent) { } } -function screenDidAppearListener({componentId, passProps, componentType}: ComponentDidAppearEvent) { - if (!(passProps as any)?.overlay && componentType === 'Component') { +function screenDidAppearListener({componentId, componentType}: ComponentDidAppearEvent) { + if (!OVERLAY_SCREENS.has(componentId) && componentType === 'Component') { NavigationStore.addNavigationComponentId(componentId); } }