mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-09 21:26:14 +03:00
Simplify room events
This commit is contained in:
parent
f99d70500c
commit
a8bd234aa4
@ -7,7 +7,7 @@ use client::{proto, Client, PeerId, TypedEnvelope, User, UserStore};
|
||||
use collections::{BTreeMap, HashSet};
|
||||
use futures::StreamExt;
|
||||
use gpui::{AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task};
|
||||
use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate, Sid};
|
||||
use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate};
|
||||
use postage::stream::Stream;
|
||||
use project::Project;
|
||||
use std::{mem, os::unix::prelude::OsStrExt, sync::Arc};
|
||||
@ -18,13 +18,8 @@ pub enum Event {
|
||||
ParticipantLocationChanged {
|
||||
participant_id: PeerId,
|
||||
},
|
||||
RemoteVideoTrackShared {
|
||||
RemoteVideoTracksChanged {
|
||||
participant_id: PeerId,
|
||||
track_id: Sid,
|
||||
},
|
||||
RemoteVideoTrackUnshared {
|
||||
peer_id: PeerId,
|
||||
track_id: Sid,
|
||||
},
|
||||
RemoteProjectShared {
|
||||
owner: Arc<User>,
|
||||
@ -448,9 +443,8 @@ impl Room {
|
||||
live_kit_track: track,
|
||||
}),
|
||||
);
|
||||
cx.emit(Event::RemoteVideoTrackShared {
|
||||
cx.emit(Event::RemoteVideoTracksChanged {
|
||||
participant_id: peer_id,
|
||||
track_id,
|
||||
});
|
||||
}
|
||||
RemoteVideoTrackUpdate::Unsubscribed {
|
||||
@ -463,7 +457,9 @@ impl Room {
|
||||
.get_mut(&peer_id)
|
||||
.ok_or_else(|| anyhow!("unsubscribed from track by unknown participant"))?;
|
||||
participant.tracks.remove(&track_id);
|
||||
cx.emit(Event::RemoteVideoTrackUnshared { peer_id, track_id });
|
||||
cx.emit(Event::RemoteVideoTracksChanged {
|
||||
participant_id: peer_id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,16 +203,15 @@ async fn test_basic_calls(
|
||||
|
||||
assert_eq!(events_b.borrow().len(), 1);
|
||||
let event = events_b.borrow().first().unwrap().clone();
|
||||
if let call::room::Event::RemoteVideoTrackShared {
|
||||
participant_id,
|
||||
track_id,
|
||||
} = event
|
||||
{
|
||||
if let call::room::Event::RemoteVideoTracksChanged { participant_id } = event {
|
||||
assert_eq!(participant_id, client_a.peer_id().unwrap());
|
||||
room_b.read_with(cx_b, |room, _| {
|
||||
assert!(room.remote_participants()[&client_a.peer_id().unwrap()]
|
||||
.tracks
|
||||
.contains_key(&track_id));
|
||||
assert_eq!(
|
||||
room.remote_participants()[&client_a.peer_id().unwrap()]
|
||||
.tracks
|
||||
.len(),
|
||||
1
|
||||
);
|
||||
});
|
||||
} else {
|
||||
panic!("unexpected event")
|
||||
|
@ -2621,15 +2621,9 @@ impl Workspace {
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
match event {
|
||||
call::room::Event::ParticipantLocationChanged {
|
||||
participant_id: peer_id,
|
||||
}
|
||||
| call::room::Event::RemoteVideoTrackShared {
|
||||
participant_id: peer_id,
|
||||
..
|
||||
}
|
||||
| call::room::Event::RemoteVideoTrackUnshared { peer_id, .. } => {
|
||||
self.leader_updated(*peer_id, cx);
|
||||
call::room::Event::ParticipantLocationChanged { participant_id }
|
||||
| call::room::Event::RemoteVideoTracksChanged { participant_id } => {
|
||||
self.leader_updated(*participant_id, cx);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user