Update chat panel with current channel

This commit is contained in:
Conrad Irwin 2024-01-12 10:23:22 -07:00
parent bc09ce6ffc
commit dc158f708f
3 changed files with 18 additions and 1 deletions

View file

@ -442,6 +442,8 @@ impl ActiveCall {
.location .location
.as_ref() .as_ref()
.and_then(|location| location.upgrade()); .and_then(|location| location.upgrade());
let channel_id = room.update(cx, |room, cx| room.channel_id());
cx.emit(Event::RoomJoined { channel_id });
room.update(cx, |room, cx| room.set_location(location.as_ref(), cx)) room.update(cx, |room, cx| room.set_location(location.as_ref(), cx))
} }
} else { } else {

View file

@ -26,6 +26,9 @@ pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum Event { pub enum Event {
RoomJoined {
channel_id: Option<u64>,
},
ParticipantLocationChanged { ParticipantLocationChanged {
participant_id: proto::PeerId, participant_id: proto::PeerId,
}, },

View file

@ -1,6 +1,6 @@
use crate::{channel_view::ChannelView, is_channels_feature_enabled, ChatPanelSettings}; use crate::{channel_view::ChannelView, is_channels_feature_enabled, ChatPanelSettings};
use anyhow::Result; use anyhow::Result;
use call::ActiveCall; use call::{room, ActiveCall};
use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore}; use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore};
use client::Client; use client::Client;
use collections::HashMap; use collections::HashMap;
@ -140,6 +140,18 @@ impl ChatPanel {
cx.notify(); cx.notify();
}, },
)); ));
this.subscriptions.push(cx.subscribe(
&ActiveCall::global(cx),
move |this: &mut Self, _, event: &room::Event, cx| match event {
room::Event::RoomJoined { channel_id } => {
if let Some(channel_id) = channel_id {
this.select_channel(*channel_id, None, cx)
.detach_and_log_err(cx)
}
}
_ => {}
},
));
this this
}) })