Fix listing being indexed by wrong id
This commit is contained in:
parent
748d6b7ded
commit
e59216809a
1 changed files with 10 additions and 8 deletions
18
src/conn.rs
18
src/conn.rs
|
|
@ -18,8 +18,8 @@ use tokio_tungstenite::{tungstenite, MaybeTlsStream, WebSocketStream};
|
||||||
|
|
||||||
use crate::api::packet::{Command, Packet, ParsedPacket};
|
use crate::api::packet::{Command, Packet, ParsedPacket};
|
||||||
use crate::api::{
|
use crate::api::{
|
||||||
BounceEvent, Data, HelloEvent, LoginReply, PersonalAccountView, Ping, PingReply, SessionView,
|
BounceEvent, Data, HelloEvent, LoginReply, PersonalAccountView, Ping, PingReply, SessionId,
|
||||||
SnapshotEvent, Time, UserId,
|
SessionView, SnapshotEvent, Time,
|
||||||
};
|
};
|
||||||
use crate::replies::{self, PendingReply, Replies};
|
use crate::replies::{self, PendingReply, Replies};
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ impl Joining {
|
||||||
.listing
|
.listing
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|s| (s.id.clone(), s))
|
.map(|s| (s.session_id.clone(), s))
|
||||||
.collect::<HashMap<_, _>>();
|
.collect::<HashMap<_, _>>();
|
||||||
Some(Joined {
|
Some(Joined {
|
||||||
session,
|
session,
|
||||||
|
|
@ -106,25 +106,27 @@ impl Joining {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Track nick events for listing, add InferredSessionView
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Joined {
|
pub struct Joined {
|
||||||
pub session: SessionView,
|
pub session: SessionView,
|
||||||
pub account: Option<PersonalAccountView>,
|
pub account: Option<PersonalAccountView>,
|
||||||
pub listing: HashMap<UserId, SessionView>,
|
pub listing: HashMap<SessionId, SessionView>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Joined {
|
impl Joined {
|
||||||
fn on_data(&mut self, data: &Data) {
|
fn on_data(&mut self, data: &Data) {
|
||||||
match data {
|
match data {
|
||||||
Data::JoinEvent(p) => {
|
Data::JoinEvent(p) => {
|
||||||
self.listing.insert(p.0.id.clone(), p.0.clone());
|
self.listing.insert(p.0.session_id.clone(), p.0.clone());
|
||||||
}
|
}
|
||||||
Data::SendEvent(p) => {
|
Data::SendEvent(p) => {
|
||||||
self.listing
|
self.listing
|
||||||
.insert(p.0.sender.id.clone(), p.0.sender.clone());
|
.insert(p.0.sender.session_id.clone(), p.0.sender.clone());
|
||||||
}
|
}
|
||||||
Data::PartEvent(p) => {
|
Data::PartEvent(p) => {
|
||||||
self.listing.remove(&p.0.id);
|
self.listing.remove(&p.0.session_id);
|
||||||
}
|
}
|
||||||
Data::NetworkEvent(p) => {
|
Data::NetworkEvent(p) => {
|
||||||
if p.r#type == "partition" {
|
if p.r#type == "partition" {
|
||||||
|
|
@ -134,7 +136,7 @@ impl Joined {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Data::NickEvent(p) => {
|
Data::NickEvent(p) => {
|
||||||
if let Some(session) = self.listing.get_mut(&p.id) {
|
if let Some(session) = self.listing.get_mut(&p.session_id) {
|
||||||
session.name = p.to.clone();
|
session.name = p.to.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue