diff options
author | Hailey <me@haileyok.com> | 2024-05-09 10:04:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 10:04:05 -0700 |
commit | 17e3b946cb5fb59f5d8cd115906daa38ca8a8124 (patch) | |
tree | 59a28bc365b3154ac073aa03a3afa2517c93b1a6 /src/screens/Messages/List/index.tsx | |
parent | 13418455376bb6573c45f5fb4a023cab34d40d3e (diff) | |
download | voidsky-17e3b946cb5fb59f5d8cd115906daa38ca8a8124.tar.zst |
Handle push notifications for DMs (#3895)
* add some better handling for notifications prep merge move `useNotificationsListener` into shell progress better structure only show messages notifications while using app if it is the current account progress only emit on native current chat emitter only show alerts for the current chat type add logs setup handlers * remove event emitter * just needs cleanup * oops * remove unnecessary `queryClient` param * few fixes * cleanup * nit * remove folds * remove comment * simplify if * add back invalidate * comment out other navigations for now * rename type * handle various navigation cases * push to conversation from notification * update badge in all cases except `chat-message` * ensure no duplicate notifications * rm unused `animationOnReplace` * revert to using `goBack` in the conversation header * add todo comment
Diffstat (limited to 'src/screens/Messages/List/index.tsx')
-rw-r--r-- | src/screens/Messages/List/index.tsx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/screens/Messages/List/index.tsx b/src/screens/Messages/List/index.tsx index 4d218bda8..6c07073a8 100644 --- a/src/screens/Messages/List/index.tsx +++ b/src/screens/Messages/List/index.tsx @@ -40,11 +40,12 @@ import {ClipClopGate} from '../gate' import {useDmServiceUrlStorage} from '../Temp/useDmServiceUrlStorage' type Props = NativeStackScreenProps<MessagesTabNavigatorParams, 'Messages'> -export function MessagesScreen({navigation}: Props) { +export function MessagesScreen({navigation, route}: Props) { const {_} = useLingui() const t = useTheme() const newChatControl = useDialogControl() const {gtMobile} = useBreakpoints() + const pushToConversation = route.params?.pushToConversation // TEMP const {serviceUrl, setServiceUrl} = useDmServiceUrlStorage() @@ -57,6 +58,19 @@ export function MessagesScreen({navigation}: Props) { ) }, [serviceUrl]) + // Whenever we have `pushToConversation` set, it means we pressed a notification for a chat without being on + // this tab. We should immediately push to the conversation after pressing the notification. + // After we push, reset with `setParams` so that this effect will fire next time we press a notification, even if + // the conversation is the same as before + React.useEffect(() => { + if (pushToConversation) { + navigation.navigate('MessagesConversation', { + conversation: pushToConversation, + }) + navigation.setParams({pushToConversation: undefined}) + } + }, [navigation, pushToConversation]) + const renderButton = useCallback(() => { return ( <Link |