Skip to content

Commit

Permalink
chore: removes unused track param (#1195)
Browse files Browse the repository at this point in the history
The `track` parameter in `notifyTrackMuteStateChanged` isn't used and is now removed from the function's signature. See: #1127

Also, this PR fixes a potential issue when leaving a call after a user is disconnected.
  • Loading branch information
oliverlaz authored Dec 11, 2023
1 parent f129979 commit 8ac84eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
22 changes: 3 additions & 19 deletions packages/client/src/rtc/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,7 @@ export class Publisher {
'info',
`Track ${TrackType[trackType]} has ended, notifying the SFU`,
);
await this.notifyTrackMuteStateChanged(
mediaStream,
track,
trackType,
true,
);
await this.notifyTrackMuteStateChanged(mediaStream, trackType, true);
// clean-up, this event listener needs to run only once.
track.removeEventListener('ended', handleTrackEnded);
};
Expand Down Expand Up @@ -295,12 +290,7 @@ export class Publisher {
await transceiver.sender.replaceTrack(track);
}

await this.notifyTrackMuteStateChanged(
mediaStream,
track,
trackType,
false,
);
await this.notifyTrackMuteStateChanged(mediaStream, trackType, false);
};

/**
Expand All @@ -325,12 +315,7 @@ export class Publisher {
: (transceiver.sender.track.enabled = false);
// We don't need to notify SFU if unpublishing in response to remote soft mute
if (this.state.localParticipant?.publishedTracks.includes(trackType)) {
await this.notifyTrackMuteStateChanged(
undefined,
transceiver.sender.track,
trackType,
true,
);
await this.notifyTrackMuteStateChanged(undefined, trackType, true);
}
}
};
Expand Down Expand Up @@ -369,7 +354,6 @@ export class Publisher {

private notifyTrackMuteStateChanged = async (
mediaStream: MediaStream | undefined,
track: MediaStreamTrack,
trackType: TrackType,
isMuted: boolean,
) => {
Expand Down
15 changes: 9 additions & 6 deletions packages/client/src/store/stateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { BehaviorSubject, Observable } from 'rxjs';
import type { Patch } from './rxUtils';
import * as RxUtils from './rxUtils';
import { Call } from '../Call';
import type { OwnUserResponse } from '../coordinator/connection/types';
import { CallingState } from './CallState';
import type { OwnUserResponse } from '../gen/coordinator';
import { getLogger } from '../logger';

export class StreamVideoWriteableStateStore {
Expand All @@ -22,12 +23,14 @@ export class StreamVideoWriteableStateStore {
this.connectedUserSubject.subscribe(async (user) => {
// leave all calls when the user disconnects.
if (!user) {
const logger = getLogger(['client-state']);
for (const call of this.calls) {
getLogger(['client-state'])(
'info',
`User disconnected, leaving call: ${call.cid}`,
);
await call.leave();
if (call.state.callingState === CallingState.LEFT) continue;

logger('info', `User disconnected, leaving call: ${call.cid}`);
await call.leave().catch((err) => {
logger('error', `Error leaving call: ${call.cid}`, err);
});
}
}
});
Expand Down

0 comments on commit 8ac84eb

Please sign in to comment.