From cf9feeae684d684c907d685abd5975a3db3d0fa4 Mon Sep 17 00:00:00 2001 From: lafay <2021211506@stu.hit.edu.cn> Date: Tue, 28 Apr 2026 14:53:32 +0800 Subject: [PATCH] feat(notification): enhance chat notification routing with flexible field handling Support both 'chat_message' and 'chat' notification types with flexible field name handling (snake_case and camelCase variants). Add groupId and groupName parameters for group chats, and fall back to notifications screen when conversationId is missing. --- app/_layout.tsx | 29 ++++++++++++++----- .../components/ChatScreen/ChatHeader.tsx | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/_layout.tsx b/app/_layout.tsx index 54b2c07..8d4f537 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -155,13 +155,28 @@ function NotificationBootstrap() { const extras = message.extras || {}; const notifType = extras.notification_type || message.notificationType; - if (notifType === 'chat_message' && extras.conversation_id) { - const isGroup = extras.conversation_type === 'group'; - router.push( - `/chat/${encodeURIComponent(extras.conversation_id)}${ - isGroup ? '?isGroupChat=1' : extras.sender_id ? `?userId=${encodeURIComponent(extras.sender_id)}` : '' - }` - ); + if (notifType === 'chat_message' || notifType === 'chat') { + const conversationId = extras.conversation_id || extras.conversationId; + const senderId = extras.sender_id || extras.senderId; + const conversationType = extras.conversation_type || extras.conversationType; + const groupId = extras.group_id || extras.groupId; + const groupName = extras.group_name || extras.groupName; + + if (conversationId) { + const isGroup = conversationType === 'group'; + const q = new URLSearchParams(); + if (isGroup) { + q.set('isGroupChat', '1'); + if (groupId) q.set('groupId', groupId); + if (groupName) q.set('groupName', groupName); + } else if (senderId) { + q.set('userId', senderId); + } + const qs = q.toString(); + router.push(`/chat/${encodeURIComponent(conversationId)}${qs ? `?${qs}` : ''}`); + } else { + router.push('/messages/notifications'); + } } else { router.push('/messages/notifications'); } diff --git a/src/screens/message/components/ChatScreen/ChatHeader.tsx b/src/screens/message/components/ChatScreen/ChatHeader.tsx index fe0ec9d..6c155e0 100644 --- a/src/screens/message/components/ChatScreen/ChatHeader.tsx +++ b/src/screens/message/components/ChatScreen/ChatHeader.tsx @@ -56,6 +56,7 @@ export const ChatHeader: React.FC = ({ headerName: { ...baseStyles.headerName, fontSize: isWideScreen ? 19 : 17, + maxWidth: isWideScreen ? 190 : 170, }, memberCount: { ...baseStyles.memberCount,