Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,9 @@ extension RoomContext {
return randomColor
}

/// Returns the color for a chat message sender, matching the live participant
/// box color when the sender name corresponds to a connected participant.
func getColorForMessage(senderName: String?) -> Color {
// Try to find a live participant whose name or identity matches the sender
if let senderName = senderName,
let match = room.allParticipants.values.first(where: {
$0.name == senderName || $0.identity?.stringValue == senderName
}) {
// Use the same key as participant boxes so colors stay in sync
let participantKey = match.sid?.stringValue ?? match.identity?.stringValue
return getColorForParticipan(participantId: participantKey)
}
// No live participant match — key by sender name
// Always key by senderName so history and live messages
// from the same sender share the same cached color.
return getColorForParticipan(participantId: senderName)
}
}
Expand Down