[Chat] Handle new chat notification reasons (#10530)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-05-20 18:20:35 +03:00
committed by GitHub
parent 9cad883ab8
commit c1817d3425
3 changed files with 136 additions and 20 deletions
+20 -8
View File
@@ -22,8 +22,9 @@ import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher'
import {useColorSchemeStyle} from '#/lib/hooks/useColorSchemeStyle'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {
type ChatNotificationPayload,
getNotificationPayload,
type NotificationPayload,
isChatNotificationPayload,
notificationToURL,
storePayloadForAccountSwitch,
} from '#/lib/hooks/useNotificationHandler'
@@ -926,14 +927,14 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
const linkingUrl = Linking.useLinkingURL()
/**
* Handle navigation to a conversation, or prepares for account switch.
* Handle navigation to the messages tab, or prepares for account switch.
*
* Non-reactive because we need the latest data from some hooks
* after an async call - sfn
*/
const handleChatMessage = useNonReactiveCallback(
(payload: Extract<NotificationPayload, {reason: 'chat-message'}>) => {
notyLogger.debug(`handleChatMessage`, {payload})
const handleChatNotification = useNonReactiveCallback(
(payload: ChatNotificationPayload) => {
notyLogger.debug(`handleChatNotification`, {payload})
if (payload.recipientDid !== currentAccount?.did) {
// handled in useNotificationHandler after account switch finishes
@@ -946,7 +947,13 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
} else {
setShowLoggedOut(true)
}
} else {
} else if (
payload.reason === 'chat-message' ||
payload.reason === 'chat-reaction' ||
payload.reason === 'chat-added-to-group'
) {
// chat-added-to-group routes to the convo because the recipient was
// just added and now has access.
// @ts-expect-error nested navigators aren't typed -sfn
navigate('MessagesTab', {
screen: 'Messages',
@@ -954,6 +961,11 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
pushToConversation: payload.convoId,
},
})
} else {
// chat-removed-from-group, chat-join-request-rejected: the convo is
// no longer accessible to the recipient, so just open the list.
// @ts-expect-error nested navigators aren't typed -sfn
navigate('MessagesTab', {screen: 'Messages'})
}
},
)
@@ -989,8 +1001,8 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
causedBoot: true,
})
if (payload.reason === 'chat-message') {
handleChatMessage(payload)
if (isChatNotificationPayload(payload)) {
handleChatNotification(payload)
} else {
const path = notificationToURL(payload)