♻️ 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, required String accountId,
@Default(null) SnAccount? account, @Default(null) SnAccount? account,
required DateTime joinedAt, required DateTime joinedAt,
@Default(false) bool isLocal,
}) = _CallParticipant; }) = _CallParticipant;
factory CallParticipant.fromJson(Map<String, dynamic> json) => factory CallParticipant.fromJson(Map<String, dynamic> json) =>

View File

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

View File

@@ -14,11 +14,13 @@ class WebRTCParticipant {
bool isAudioEnabled = true; bool isAudioEnabled = true;
bool isVideoEnabled = false; bool isVideoEnabled = false;
bool isConnected = false; bool isConnected = false;
bool isLocal = false;
WebRTCParticipant({ WebRTCParticipant({
required this.id, required this.id,
required this.name, required this.name,
required this.userinfo, 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) _participants.values.where((e) => e.isLocal).firstOrNull?.isAudioEnabled = true;
for (final participant in _participants.values) {
participant.isAudioEnabled = enabled;
_participantController.add(participant);
}
} }
Future<void> toggleCamera(bool enabled) async { 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) _participants.values.where((e) => e.isLocal).firstOrNull?.isVideoEnabled = true;
for (final participant in _participants.values) {
participant.isVideoEnabled = enabled;
_participantController.add(participant);
}
} }
List<WebRTCParticipant> get participants => _participants.values.toList(); List<WebRTCParticipant> get participants => _participants.values.toList();