Skip to content

Commit

Permalink
EmojiPickerScreen: Use plain-old navigation.goBack()
Browse files Browse the repository at this point in the history
We don't like using NavigationService (zulip#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.
  • Loading branch information
chrisbobbe committed Mar 5, 2022
1 parent a046057 commit 3cb0719
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/emoji/EmojiPickerScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 3cb0719

Please sign in to comment.