From 2b0d2f67491d9a5cb37ff3a3bfe3b957d2a45366 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Wed, 2 Mar 2022 16:07:48 -0800 Subject: [PATCH] EmojiPickerScreen: Use plain-old navigation.goBack() We don't like using NavigationService (#4417), so this is nice to be able to do. Not *quite* NFC: if we somehow manage to have two consecutive EmojiPickerScreens at the top of the stack, we'll now just pop one of them instead of both, because we lose `navigateBack`'s special logic with its `sameRoutesCount` value. But that logic is designed for `ChatScreen` -- we do expect to have multiple of `ChatScreen`s at the top of the stack sometimes. We don't expect that with `EmojiPickerScreen`s. --- src/emoji/EmojiPickerScreen.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/emoji/EmojiPickerScreen.js b/src/emoji/EmojiPickerScreen.js index 8284e7e6b99..47b66071347 100644 --- a/src/emoji/EmojiPickerScreen.js +++ b/src/emoji/EmojiPickerScreen.js @@ -7,14 +7,12 @@ import { FlatList } from 'react-native'; import { TranslationContext } from '../boot/TranslationProvider'; import type { RouteProp } from '../react-navigation'; import type { AppNavigationProp } from '../nav/AppNavigator'; -import * as NavigationService from '../nav/NavigationService'; import * as api from '../api'; import Screen from '../common/Screen'; import EmojiRow from './EmojiRow'; import { getFilteredEmojis, reactionTypeFromEmojiType } from './data'; import { useSelector } from '../react-redux'; import { getAuth, getActiveImageEmojiByName } from '../selectors'; -import { navigateBack } from '../nav/navActions'; import * as logging from '../utils/logging'; import { showToast } from '../utils/info'; @@ -24,7 +22,7 @@ type Props = $ReadOnly<{| |}>; export default function EmojiPickerScreen(props: Props): Node { - const { route } = props; + const { navigation, route } = props; const { messageId } = route.params; const _ = useContext(TranslationContext); @@ -46,9 +44,9 @@ export default function EmojiPickerScreen(props: Props): Node { logging.error('Error adding reaction emoji', err); showToast(_('Failed to add reaction')); }); - NavigationService.dispatch(navigateBack()); + navigation.goBack(); }, - [auth, messageId, _], + [auth, messageId, _, navigation], ); const emojiNames = getFilteredEmojis(filter, activeImageEmojiByName);