Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Clean up screenshare (#44945)

Conrad Irwinee2a4a9d37de
diff --git a/crates/call/src/call_impl/room.rs b/crates/call/src/call_impl/room.rs
index fc15b4e4395..ccc8c067c25 100644
--- a/crates/call/src/call_impl/room.rs
+++ b/crates/call/src/call_impl/room.rs
@@ -305,6 +305,7 @@ impl Room {
pub(crate) fn leave(&mut self, cx: &mut Context<Self>) -> Task<Result<()>> {
cx.notify();
+ self.emit_video_track_unsubscribed_events(cx);
self.leave_internal(cx)
}
@@ -352,6 +353,14 @@ impl Room {
self.maintain_connection.take();
}
+ fn emit_video_track_unsubscribed_events(&self, cx: &mut Context<Self>) {
+ for participant in self.remote_participants.values() {
+ for sid in participant.video_tracks.keys() {
+ cx.emit(Event::RemoteVideoTrackUnsubscribed { sid: sid.clone() });
+ }
+ }
+ }
+
async fn maintain_connection(
this: WeakEntity<Self>,
client: Arc<Client>,
@@ -882,6 +891,9 @@ impl Room {
project_id: project.id,
});
}
+ for sid in participant.video_tracks.keys() {
+ cx.emit(Event::RemoteVideoTrackUnsubscribed { sid: sid.clone() });
+ }
false
}
});
diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs
index 3c009f613ea..56456027469 100644
--- a/crates/workspace/src/shared_screen.rs
+++ b/crates/workspace/src/shared_screen.rs
@@ -42,6 +42,11 @@ impl SharedScreen {
})
.detach();
+ cx.observe_release(&room, |_, _, cx| {
+ cx.emit(Event::Close);
+ })
+ .detach();
+
let view = cx.new(|cx| RemoteVideoTrackView::new(track.clone(), window, cx));
cx.subscribe(&view, |_, _, ev, cx| match ev {
call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close),