Ensure notifications are dismissed

Before this change if you joined a project without clicking on the
notification it would never disappear.

Fix a related bug where if you have more than one monitor, the
notification was only dismissed from one of them.
This commit is contained in:
Conrad Irwin 2023-10-02 10:56:32 -06:00
parent 9dc292772a
commit 39af2bb0a4
6 changed files with 61 additions and 21 deletions

View file

@ -948,7 +948,7 @@ impl CollabTitlebarItem {
fn render_face_pile(
&self,
user: &User,
replica_id: Option<ReplicaId>,
_replica_id: Option<ReplicaId>,
peer_id: PeerId,
location: Option<ParticipantLocation>,
muted: bool,

View file

@ -7,7 +7,7 @@ mod face_pile;
mod incoming_call_notification;
mod notifications;
mod panel_settings;
mod project_shared_notification;
pub mod project_shared_notification;
mod sharing_status_indicator;
use call::{report_call_event_for_room, ActiveCall, Room};

View file

@ -40,7 +40,8 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
.push(window);
}
}
room::Event::RemoteProjectUnshared { project_id } => {
room::Event::RemoteProjectUnshared { project_id }
| room::Event::RemoteProjectInvitationDiscarded { project_id } => {
if let Some(windows) = notification_windows.remove(&project_id) {
for window in windows {
window.remove(cx);
@ -54,6 +55,13 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
}
}
}
room::Event::RemoteProjectJoined { project_id } => {
if let Some(windows) = notification_windows.remove(&project_id) {
for window in windows {
window.remove(cx);
}
}
}
_ => {}
})
.detach();
@ -82,7 +90,6 @@ impl ProjectSharedNotification {
}
fn join(&mut self, cx: &mut ViewContext<Self>) {
cx.remove_window();
if let Some(app_state) = self.app_state.upgrade() {
workspace::join_remote_project(self.project_id, self.owner.id, app_state, cx)
.detach_and_log_err(cx);
@ -90,7 +97,15 @@ impl ProjectSharedNotification {
}
fn dismiss(&mut self, cx: &mut ViewContext<Self>) {
cx.remove_window();
if let Some(active_room) =
ActiveCall::global(cx).read_with(cx, |call, _| call.room().cloned())
{
active_room.update(cx, |_, cx| {
cx.emit(room::Event::RemoteProjectInvitationDiscarded {
project_id: self.project_id,
});
});
}
}
fn render_owner(&self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {