From b34477458e0e0404edf28bf62e9a4b375713452f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 15 Mar 2023 15:19:27 -0700 Subject: [PATCH] Close remote project windows when leaving a call --- crates/call/src/room.rs | 1 + crates/project/src/project.rs | 5 +++++ crates/workspace/src/workspace.rs | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/crates/call/src/room.rs b/crates/call/src/room.rs index 3a662458f2..eeb8a6a5d8 100644 --- a/crates/call/src/room.rs +++ b/crates/call/src/room.rs @@ -275,6 +275,7 @@ impl Room { if let Some(project) = project.upgrade(cx) { project.update(cx, |project, cx| { project.disconnected_from_host(cx); + project.close(cx); }); } } diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index a164b5b885..fb4e6b5b80 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -175,6 +175,7 @@ pub enum Event { }, RemoteIdChanged(Option), DisconnectedFromHost, + Closed, CollaboratorUpdated { old_peer_id: proto::PeerId, new_peer_id: proto::PeerId, @@ -1172,6 +1173,10 @@ impl Project { } } + pub fn close(&mut self, cx: &mut ModelContext) { + cx.emit(Event::Closed); + } + pub fn is_read_only(&self) -> bool { match &self.client_state { Some(ProjectClientState::Remote { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 3b1351860b..f752e6d2b6 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -598,6 +598,11 @@ impl Workspace { cx.blur(); } + project::Event::Closed => { + let window_id = cx.window_id(); + cx.remove_window(window_id); + } + _ => {} } cx.notify()