♻️ Proper local participant

This commit is contained in:
2025-10-19 19:06:14 +08:00
parent f4b28c3fa2
commit a2576abee0
3 changed files with 5 additions and 12 deletions

View File

@@ -152,7 +152,6 @@ sealed class CallParticipant with _$CallParticipant {
required String accountId,
@Default(null) SnAccount? account,
required DateTime joinedAt,
@Default(false) bool isLocal,
}) = _CallParticipant;
factory CallParticipant.fromJson(Map<String, dynamic> json) =>

View File

@@ -145,6 +145,7 @@ class CallNotifier extends _$CallNotifier {
id: _webrtcManager!.roomId,
name: userinfo.nick,
userinfo: userinfo,
isLocal: true,
)..remoteStream = _webrtcManager!.localStream, // Access local stream
);
@@ -178,7 +179,6 @@ class CallNotifier extends _$CallNotifier {
accountId: p.userinfo.id,
account: p.userinfo,
joinedAt: DateTime.now(),
isLocal: true,
);
return CallParticipantLive(
participant: participantInfo,

View File

@@ -14,11 +14,13 @@ class WebRTCParticipant {
bool isAudioEnabled = true;
bool isVideoEnabled = false;
bool isConnected = false;
bool isLocal = false;
WebRTCParticipant({
required this.id,
required this.name,
required this.userinfo,
this.isLocal = false,
});
}
@@ -271,11 +273,7 @@ class WebRTCManager {
}
}
// Update audio enabled state for all participants (they share the same local stream)
for (final participant in _participants.values) {
participant.isAudioEnabled = enabled;
_participantController.add(participant);
}
_participants.values.where((e) => e.isLocal).firstOrNull?.isAudioEnabled = true;
}
Future<void> toggleCamera(bool enabled) async {
@@ -285,11 +283,7 @@ class WebRTCManager {
});
}
// Update video enabled state for all participants (they share the same local stream)
for (final participant in _participants.values) {
participant.isVideoEnabled = enabled;
_participantController.add(participant);
}
_participants.values.where((e) => e.isLocal).firstOrNull?.isVideoEnabled = true;
}
List<WebRTCParticipant> get participants => _participants.values.toList();