feat(notification): enhance chat notification routing with flexible field handling
All checks were successful
Frontend CI / ota-android (push) Successful in 1m11s
Frontend CI / build-and-push-web (push) Successful in 3m22s
Frontend CI / build-android-apk (push) Successful in 1h31m46s

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.
This commit is contained in:
lafay
2026-04-28 14:53:32 +08:00
parent 2432f7bc1e
commit cf9feeae68
2 changed files with 23 additions and 7 deletions

View File

@@ -155,13 +155,28 @@ function NotificationBootstrap() {
const extras = message.extras || {}; const extras = message.extras || {};
const notifType = extras.notification_type || message.notificationType; const notifType = extras.notification_type || message.notificationType;
if (notifType === 'chat_message' && extras.conversation_id) { if (notifType === 'chat_message' || notifType === 'chat') {
const isGroup = extras.conversation_type === 'group'; const conversationId = extras.conversation_id || extras.conversationId;
router.push( const senderId = extras.sender_id || extras.senderId;
`/chat/${encodeURIComponent(extras.conversation_id)}${ const conversationType = extras.conversation_type || extras.conversationType;
isGroup ? '?isGroupChat=1' : extras.sender_id ? `?userId=${encodeURIComponent(extras.sender_id)}` : '' 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 { } else {
router.push('/messages/notifications'); router.push('/messages/notifications');
} }

View File

@@ -56,6 +56,7 @@ export const ChatHeader: React.FC<ChatHeaderProps> = ({
headerName: { headerName: {
...baseStyles.headerName, ...baseStyles.headerName,
fontSize: isWideScreen ? 19 : 17, fontSize: isWideScreen ? 19 : 17,
maxWidth: isWideScreen ? 190 : 170,
}, },
memberCount: { memberCount: {
...baseStyles.memberCount, ...baseStyles.memberCount,