From 99f87c366e224cf967c0ff9c2f9a4fee749d4585 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Thu, 25 Jul 2024 15:48:57 +0200 Subject: [PATCH 1/2] Only emit TrackStreamStateChanged events on changed stream state --- src/room/Room.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/room/Room.ts b/src/room/Room.ts index 3c826a3c9f..3ca46210dd 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -1446,14 +1446,17 @@ class Room extends (EventEmitter as new () => TypedEmitter) if (!pub || !pub.track) { return; } - pub.track.streamState = Track.streamStateFromProto(streamState.state); - participant.emit(ParticipantEvent.TrackStreamStateChanged, pub, pub.track.streamState); - this.emitWhenConnected( - RoomEvent.TrackStreamStateChanged, - pub, - pub.track.streamState, - participant, - ); + const newStreamState = Track.streamStateFromProto(streamState.state); + if (newStreamState !== pub.track.streamState) { + pub.track.streamState = newStreamState; + participant.emit(ParticipantEvent.TrackStreamStateChanged, pub, pub.track.streamState); + this.emitWhenConnected( + RoomEvent.TrackStreamStateChanged, + pub, + pub.track.streamState, + participant, + ); + } }); }; From 85e9fe27a98179045196921b4f445760385fc144 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Thu, 25 Jul 2024 15:49:39 +0200 Subject: [PATCH 2/2] Create strong-ladybugs-notice.md --- .changeset/strong-ladybugs-notice.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/strong-ladybugs-notice.md diff --git a/.changeset/strong-ladybugs-notice.md b/.changeset/strong-ladybugs-notice.md new file mode 100644 index 0000000000..40d088230b --- /dev/null +++ b/.changeset/strong-ladybugs-notice.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Only emit TrackStreamStateChanged events on changed stream state