Handle participants' participant index changing

This normally doesn't happen, but it can happen if a participant
loses connection ungracefully, restarts their app, and then
explicitly joins again.
This commit is contained in:
Max Brunsfeld 2023-10-09 14:45:19 -07:00
parent 90b54a45e8
commit b807b3c785

View file

@ -686,6 +686,7 @@ impl Room {
let Some(peer_id) = participant.peer_id else { let Some(peer_id) = participant.peer_id else {
continue; continue;
}; };
let participant_index = ParticipantIndex(participant.participant_index);
this.participant_user_ids.insert(participant.user_id); this.participant_user_ids.insert(participant.user_id);
let old_projects = this let old_projects = this
@ -736,8 +737,9 @@ impl Room {
if let Some(remote_participant) = if let Some(remote_participant) =
this.remote_participants.get_mut(&participant.user_id) this.remote_participants.get_mut(&participant.user_id)
{ {
remote_participant.projects = participant.projects;
remote_participant.peer_id = peer_id; remote_participant.peer_id = peer_id;
remote_participant.projects = participant.projects;
remote_participant.participant_index = participant_index;
if location != remote_participant.location { if location != remote_participant.location {
remote_participant.location = location; remote_participant.location = location;
cx.emit(Event::ParticipantLocationChanged { cx.emit(Event::ParticipantLocationChanged {
@ -749,9 +751,7 @@ impl Room {
participant.user_id, participant.user_id,
RemoteParticipant { RemoteParticipant {
user: user.clone(), user: user.clone(),
participant_index: ParticipantIndex( participant_index,
participant.participant_index,
),
peer_id, peer_id,
projects: participant.projects, projects: participant.projects,
location, location,