From 6394138c4ab0ac99225d9df5f64444a16458b6f3 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Wed, 27 Apr 2022 19:40:13 +0200 Subject: [PATCH] fix isMuted logic in view model --- src/domain/session/room/CallViewModel.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/domain/session/room/CallViewModel.ts b/src/domain/session/room/CallViewModel.ts index 3db1feb8..da526fcd 100644 --- a/src/domain/session/room/CallViewModel.ts +++ b/src/domain/session/room/CallViewModel.ts @@ -67,14 +67,6 @@ export class CallViewModel extends ViewModel { } } - get isCameraMuted(): boolean { - return this.call.muteSettings.camera; - } - - get isMicrophoneMuted(): boolean { - return this.call.muteSettings.microphone; - } - async toggleVideo() { this.call.setMuted(this.call.muteSettings.toggleCamera()); } @@ -95,11 +87,11 @@ class OwnMemberViewModel extends ViewModel implements IStreamV } get isCameraMuted(): boolean { - return this.call.muteSettings.camera ?? !!getStreamVideoTrack(this.stream); + return isMuted(this.call.muteSettings.camera, !!getStreamVideoTrack(this.stream)); } get isMicrophoneMuted(): boolean { - return this.call.muteSettings.microphone ?? !!getStreamAudioTrack(this.stream); + return isMuted(this.call.muteSettings.microphone, !!getStreamAudioTrack(this.stream)); } get avatarLetter(): string { @@ -135,11 +127,11 @@ export class CallMemberViewModel extends ViewModel implements ISt } get isCameraMuted(): boolean { - return this.member.remoteMuteSettings?.camera ?? !getStreamVideoTrack(this.stream); + return isMuted(this.member.remoteMuteSettings?.camera, !!getStreamVideoTrack(this.stream)); } get isMicrophoneMuted(): boolean { - return this.member.remoteMuteSettings?.microphone ?? !getStreamAudioTrack(this.stream); + return isMuted(this.member.remoteMuteSettings?.microphone, !!getStreamAudioTrack(this.stream)); } get avatarLetter(): string { @@ -178,3 +170,11 @@ export interface IStreamViewModel extends AvatarSource, ViewModel { get isCameraMuted(): boolean; get isMicrophoneMuted(): boolean; } + +function isMuted(muted: boolean | undefined, hasTrack: boolean) { + if (muted) { + return true; + } else { + return !hasTrack; + } +}