🐛 Bug fixes of duplication

This commit is contained in:
LittleSheep 2024-04-28 00:21:16 +08:00
parent 155f7c7999
commit 0483e99a4c

View File

@ -147,12 +147,12 @@ class _ChatCallState extends State<ChatCall> {
void autoPublish() async { void autoPublish() async {
try { try {
if(_enableVideo) await _callRoom.localParticipant?.setCameraEnabled(true); if (_enableVideo) await _callRoom.localParticipant?.setCameraEnabled(true);
} catch (error) { } catch (error) {
await context.showErrorDialog(error); await context.showErrorDialog(error);
} }
try { try {
if(_enableAudio) await _callRoom.localParticipant?.setMicrophoneEnabled(true); if (_enableAudio) await _callRoom.localParticipant?.setMicrophoneEnabled(true);
} catch (error) { } catch (error) {
await context.showErrorDialog(error); await context.showErrorDialog(error);
} }
@ -277,6 +277,14 @@ class _ChatCallState extends State<ChatCall> {
} }
} }
} }
var checklistIdx = List<String>.empty(growable: true);
userMediaTracks = userMediaTracks.where((element) {
if(checklistIdx.contains(element.participant.sid)) return false;
checklistIdx.add(element.participant.sid);
return true;
}).toList();
setState(() { setState(() {
_participantTracks = [...screenTracks, ...userMediaTracks]; _participantTracks = [...screenTracks, ...userMediaTracks];
}); });
@ -403,14 +411,21 @@ class _ChatCallState extends State<ChatCall> {
right: 0, right: 0,
top: 0, top: 0,
child: SizedBox( child: SizedBox(
height: 120, height: 120 + 16,
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: math.max(0, _participantTracks.length - 1), itemCount: math.max(0, _participantTracks.length - 1),
itemBuilder: (BuildContext context, int index) => SizedBox( itemBuilder: (BuildContext context, int index) => Padding(
width: 120, padding: const EdgeInsets.all(8.0),
height: 120, child: ClipRRect(
child: ParticipantWidget.widgetFor(_participantTracks[index + 1]), borderRadius: const BorderRadius.all(Radius.circular(8)),
child: Container(
width: 120,
height: 120,
color: Theme.of(context).cardColor,
child: ParticipantWidget.widgetFor(_participantTracks[index + 1]),
),
),
), ),
), ),
), ),