feat: real-time user profile updates and propagate avatarColor to all Avatar callsites

Broadcast user_updated events over WebSocket when profile fields change,
updating members, DM participants, friends, and cached messages in real time.
Widen useVoiceParticipantMeta to return the full user object and add a
standalone avatarColor prop to Avatar so all ~16 callsites now resolve
the user's chosen gradient color instead of falling back to hash-based colors.
This commit is contained in:
Jannis Braun
2026-03-11 01:12:12 +01:00
parent 9255683d8c
commit 3790386a5f
16 changed files with 131 additions and 12 deletions
+20
View File
@@ -57,6 +57,7 @@ interface ChatState {
markChannelUnread: (channelId: string) => void;
ackChannel: (channelId: string) => void;
onChannelAck: (channelId: string, messageId: string) => void;
updateUserInMessages: (user: { id: string; [key: string]: any }) => void;
}
/** Find which channel a message belongs to by scanning the message cache. */
@@ -593,4 +594,23 @@ export const useChatStore = create<ChatState>((set, get) => ({
return { readStates: newReadStates, unreadChannels: newUnread };
});
},
updateUserInMessages: (user: { id: string; [key: string]: any }) => {
set((state) => {
const newMessages = new Map(state.messages);
let changed = false;
for (const [channelId, msgs] of newMessages) {
let channelChanged = false;
const updated = msgs.map(m => {
if (m.userId === user.id) {
channelChanged = true;
return { ...m, user: { ...m.user, ...user } };
}
return m;
});
if (channelChanged) { newMessages.set(channelId, updated); changed = true; }
}
return changed ? { messages: newMessages } : {};
});
},
}));