Skip to content

Commit

Permalink
Cherry pick #5563 (#5565)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyan2024 authored Jan 16, 2025
1 parent 3f94c3d commit 8c42874
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/calling-stateful-client/src/CapabilitiesSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class CapabilitiesSubscriber {
private _callIdRef: CallIdRef;
private _context: CallContext;
private _capabilitiesFeature: CapabilitiesFeature;
/* @conditional-compile-remove(media-access) */
private _capabilitiesInitialized: boolean = false;

constructor(callIdRef: CallIdRef, context: CallContext, capabilities: CapabilitiesFeature) {
this._callIdRef = callIdRef;
Expand All @@ -38,12 +40,19 @@ export class CapabilitiesSubscriber {
}
/* @conditional-compile-remove(media-access) */
this.setUnmuteMicAndTurnVideoOnNotification(data);

/* @conditional-compile-remove(media-access) */
this._capabilitiesInitialized = true;
};

/* @conditional-compile-remove(media-access) */
private setUnmuteMicAndTurnVideoOnNotification = (data: CapabilitiesChangeInfo): void => {
if (data.oldValue.turnVideoOn?.isPresent !== data.newValue.turnVideoOn?.isPresent) {
if (data.oldValue.turnVideoOn?.isPresent === false && data.newValue.turnVideoOn?.isPresent) {
if (
data.oldValue.turnVideoOn?.isPresent === false &&
data.newValue.turnVideoOn?.isPresent &&
this._capabilitiesInitialized
) {
const capabilityTurnVideoOnAbsent = this._context.getState().latestNotifications.capabilityTurnVideoOnAbsent;
if (capabilityTurnVideoOnAbsent) {
this._context.deleteLatestNotification(this._callIdRef.callId, 'capabilityTurnVideoOnAbsent');
Expand Down Expand Up @@ -72,7 +81,11 @@ export class CapabilitiesSubscriber {
}
}
if (data.oldValue.unmuteMic?.isPresent !== data.newValue.unmuteMic?.isPresent) {
if (data.oldValue.unmuteMic?.isPresent === false && data.newValue.unmuteMic?.isPresent) {
if (
data.oldValue.unmuteMic?.isPresent === false &&
data.newValue.unmuteMic?.isPresent &&
this._capabilitiesInitialized
) {
const capabilityUnmuteMicAbsent = this._context.getState().latestNotifications.capabilityUnmuteMicAbsent;
if (capabilityUnmuteMicAbsent) {
this._context.deleteLatestNotification(this._callIdRef.callId, 'capabilityUnmuteMicAbsent');
Expand Down

0 comments on commit 8c42874

Please sign in to comment.