From d731accbd6d27c8d5b97bc5b7dcffff4197609e6 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 21 Feb 2024 20:00:00 +0100 Subject: [PATCH] fix: undo last commit, send full users im a dummy --- src/model.rs | 6 +++--- src/session.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/model.rs b/src/model.rs index 2b737bc..82a3068 100644 --- a/src/model.rs +++ b/src/model.rs @@ -67,9 +67,9 @@ impl User { pub fn update(&mut self, state: crate::tcp::proto::UserState) { if state.session() != self.session { tracing::warn!("updating with different session??") } if let Some(actor) = state.actor { self.actor = actor } - if let Some(name) = state.name { if !name.is_empty() { self.name = name } } - if let Some(user_id) = state.user_id { if user_id != 0 { self.user_id = Some(user_id) } } - if let Some(comment) = state.comment { if !comment.is_empty() { self.comment = Some(comment) } } + if let Some(name) = state.name { self.name = name } + if let Some(user_id) = state.user_id { self.user_id = Some(user_id) } + if let Some(comment) = state.comment { self.comment = Some(comment) } if let Some(mute) = state.mute { self.properties.mute = mute } if let Some(deaf) = state.deaf { self.properties.deaf = deaf } if let Some(suppress) = state.suppress { self.properties.suppress = suppress } diff --git a/src/session.rs b/src/session.rs index 1a79253..0d72237 100644 --- a/src/session.rs +++ b/src/session.rs @@ -136,11 +136,11 @@ impl Session { Ok(proto::Packet::UserState(user)) => { tracing::info!("user state: {:?}", user); let mut users = session.users.write().await; - let _ = session.events.send(User::from(user.clone())); // if it fails nobody is listening match users.get_mut(&user.session()) { Some(u) => u.update(user), None => { users.insert(user.session(), User::from(user)); }, } + let _ = session.events.send(users.get(&user.session()).expect("just inserted")); // if it fails nobody is listening }, Ok(pkt) => tracing::info!("ignoring packet {:?}", pkt), }