From 8a759c74c907ac2ebcf728713d0ed75b2de12353 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Sun, 4 Jan 2026 17:22:11 -0500 Subject: [PATCH] Avoid adding a user to a chat channel more than once --- rc_chat_room/src/state/chat/room.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rc_chat_room/src/state/chat/room.rs b/rc_chat_room/src/state/chat/room.rs index 3b4f2f9..62434be 100644 --- a/rc_chat_room/src/state/chat/room.rs +++ b/rc_chat_room/src/state/chat/room.rs @@ -79,7 +79,11 @@ impl ChatRoom { channel: crate::events::room_join::RoomJoined::CHANNEL, reliable: true, }); - self.online_users.push(handle); + if !self.online_users.iter().any(|other| other.name() == handle.name()) { + self.online_users.push(handle); + } else { + log::warn!("User {} tried to join channel {} again", handle.name(), self.name); + } } pub fn remove_user(&mut self, name: &str) -> bool {