Clean up screenshare (#44945)

Release Notes:

- Fixed a bug where screen-share tabs would persist after the sender (or
receiver) had left the call.
This commit is contained in:
Conrad Irwin 2025-12-15 22:10:33 -07:00 committed by GitHub
parent 829b1b5661
commit ee2a4a9d37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -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
}
});

View file

@ -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),