fix: undo last commit, send full users

im a dummy
This commit is contained in:
əlemi 2024-02-21 20:00:00 +01:00
parent 45bddfe067
commit d731accbd6
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 4 additions and 4 deletions

View file

@ -67,9 +67,9 @@ impl User {
pub fn update(&mut self, state: crate::tcp::proto::UserState) { pub fn update(&mut self, state: crate::tcp::proto::UserState) {
if state.session() != self.session { tracing::warn!("updating with different session??") } if state.session() != self.session { tracing::warn!("updating with different session??") }
if let Some(actor) = state.actor { self.actor = actor } 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(name) = state.name { self.name = name }
if let Some(user_id) = state.user_id { if user_id != 0 { self.user_id = Some(user_id) } } if let Some(user_id) = state.user_id { self.user_id = Some(user_id) }
if let Some(comment) = state.comment { if !comment.is_empty() { self.comment = Some(comment) } } if let Some(comment) = state.comment { self.comment = Some(comment) }
if let Some(mute) = state.mute { self.properties.mute = mute } if let Some(mute) = state.mute { self.properties.mute = mute }
if let Some(deaf) = state.deaf { self.properties.deaf = deaf } if let Some(deaf) = state.deaf { self.properties.deaf = deaf }
if let Some(suppress) = state.suppress { self.properties.suppress = suppress } if let Some(suppress) = state.suppress { self.properties.suppress = suppress }

View file

@ -136,11 +136,11 @@ impl Session {
Ok(proto::Packet::UserState(user)) => { Ok(proto::Packet::UserState(user)) => {
tracing::info!("user state: {:?}", user); tracing::info!("user state: {:?}", user);
let mut users = session.users.write().await; 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()) { match users.get_mut(&user.session()) {
Some(u) => u.update(user), Some(u) => u.update(user),
None => { users.insert(user.session(), User::from(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), Ok(pkt) => tracing::info!("ignoring packet {:?}", pkt),
} }