Skip to content

Commit 01e8415

Browse files
authored
fix: fix async call for update participant info (#897)
close #895
1 parent 02c2f95 commit 01e8415

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

lib/src/core/room.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
636636
return null;
637637
}
638638

639-
RemoteParticipant _getOrCreateRemoteParticipant(String identity, lk_models.ParticipantInfo? info) {
639+
Future<RemoteParticipant> _getOrCreateRemoteParticipant(String identity, lk_models.ParticipantInfo? info) async {
640640
RemoteParticipant? participant = _remoteParticipants[identity];
641641
if (participant != null) {
642642
if (info != null) {
643-
participant.updateFromInfo(info);
643+
await participant.updateFromInfo(info);
644644
}
645645
return participant;
646646
}
@@ -654,7 +654,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
654654
name: '',
655655
);
656656
} else {
657-
participant = RemoteParticipant.fromInfo(
657+
participant = await RemoteParticipant.createFromInfo(
658658
room: this,
659659
info: info,
660660
);
@@ -689,7 +689,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
689689
continue;
690690
}
691691

692-
final participant = _getOrCreateRemoteParticipant(info.identity, info);
692+
final participant = await _getOrCreateRemoteParticipant(info.identity, info);
693693

694694
if (isNew) {
695695
hasChanged = true;

lib/src/participant/remote.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,18 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
4646
name: name,
4747
);
4848

49-
@internal
50-
RemoteParticipant.fromInfo({
49+
static Future<RemoteParticipant> createFromInfo({
5150
required Room room,
5251
required lk_models.ParticipantInfo info,
53-
}) : super(
54-
room: room,
55-
sid: info.sid,
56-
identity: info.identity,
57-
name: info.name,
58-
) {
59-
updateFromInfo(info);
52+
}) async {
53+
final participant = RemoteParticipant(
54+
room: room,
55+
sid: info.identity,
56+
identity: info.identity,
57+
name: info.name,
58+
);
59+
await participant.updateFromInfo(info);
60+
return participant;
6061
}
6162

6263
/// A convenience property to get all video tracks.
@@ -192,8 +193,7 @@ class RemoteParticipant extends Participant<RemoteTrackPublication> {
192193
final newPubs = <RemoteTrackPublication>{};
193194

194195
for (final trackInfo in info.tracks) {
195-
final RemoteTrackPublication? pub =
196-
getTrackPublicationBySid(trackInfo.sid);
196+
final RemoteTrackPublication? pub = getTrackPublicationBySid(trackInfo.sid);
197197
if (pub == null) {
198198
final RemoteTrackPublication pub;
199199
if (trackInfo.type == lk_models.TrackType.VIDEO) {

0 commit comments

Comments
 (0)