fix: open private chat from sidebar search
- openOrCreatePrivate: load chat by ID directly (skip stale list lookup) - GET /api/chats/🆔 resolve title/avatar/privateUserId for private chats (was returning null title, causing chat area to behave unexpectedly) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,17 +89,21 @@ export default async function chatRoutes(app: FastifyInstance) {
|
||||
|
||||
const onlineSet = new Set(connections.keys());
|
||||
|
||||
// For private chats, resolve title/avatar/color from the other member
|
||||
const other = chat.type === 'private' ? members.find((m: any) => m.id !== userId) : null;
|
||||
|
||||
return {
|
||||
id: chat.id,
|
||||
type: chat.type,
|
||||
title: chat.title,
|
||||
title: chat.type === 'private' ? (other?.display_name || '') : chat.title,
|
||||
description: chat.description,
|
||||
avatarColor: chat.avatar_color,
|
||||
avatar: chat.avatar || null,
|
||||
avatarColor: chat.type === 'private' ? (other?.avatar_color || chat.avatar_color) : chat.avatar_color,
|
||||
avatar: chat.type === 'private' ? (other?.avatar || null) : (chat.avatar || null),
|
||||
isPublic: chat.is_public,
|
||||
myRole: member.role,
|
||||
canSendMessages: member.can_send_messages,
|
||||
canAddMembers: member.can_add_members,
|
||||
privateUserId: chat.type === 'private' ? (other?.id || null) : null,
|
||||
createdAt: chat.created_at,
|
||||
members: members.map(m => ({
|
||||
id: m.id, username: m.username, displayName: m.display_name,
|
||||
|
||||
Reference in New Issue
Block a user