Skip to content

Commit b74da67

Browse files
wjaykimlukasIO
andauthored
fix: emit mute status event for unsubscribed user (#625)
* fix: emit mute status event for unsubscribed user * fix: check if muted changed in updateInfo * refactor: check metadataMuted changed later * Create .changeset/blue-planes-pretend.md --------- Co-authored-by: lukasIO <[email protected]>
1 parent 2166c30 commit b74da67

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/blue-planes-pretend.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
Emit mute status events also for unsubscribed publications

src/room/track/RemoteTrackPublication.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,13 @@ export default class RemoteTrackPublication extends TrackPublication {
207207
/** @internal */
208208
updateInfo(info: TrackInfo) {
209209
super.updateInfo(info);
210+
const prevMetadataMuted = this.metadataMuted;
210211
this.metadataMuted = info.muted;
211-
this.track?.setMuted(info.muted);
212+
if (this.track) {
213+
this.track.setMuted(info.muted);
214+
} else if (prevMetadataMuted !== info.muted) {
215+
this.emit(info.muted ? TrackEvent.Muted : TrackEvent.Unmuted);
216+
}
212217
}
213218

214219
private emitSubscriptionUpdateIfChanged(previousStatus: TrackPublication.SubscriptionStatus) {

0 commit comments

Comments
 (0)