From eec44702f743070cd5cbb24f84c38a92b83577ff Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Wed, 6 Nov 2024 16:33:53 +0000 Subject: [PATCH] Make local field based on view model class not observable --- src/state/CallViewModel.ts | 1 + src/state/MediaViewModel.ts | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 10c56eea..0052067e 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -317,6 +317,7 @@ class ScreenShare { this.participant.asObservable(), encryptionSystem, liveKitRoom, + participant.isLocal, ); } diff --git a/src/state/MediaViewModel.ts b/src/state/MediaViewModel.ts index 4fdf1131..e3f244f9 100644 --- a/src/state/MediaViewModel.ts +++ b/src/state/MediaViewModel.ts @@ -207,14 +207,6 @@ export enum EncryptionStatus { } abstract class BaseMediaViewModel extends ViewModel { - /** - * Whether the media belongs to the local user. - */ - public readonly local: Observable = this.participant.pipe( - // We can assume, that the user is not local if the participant is undefined - // We assume the local LK participant will always be available. - map((p) => p?.isLocal ?? false), - ); /** * The LiveKit video track for this media. */ @@ -414,6 +406,7 @@ abstract class BaseUserMediaViewModel extends BaseMediaViewModel { * The local participant's user media. */ export class LocalUserMediaViewModel extends BaseUserMediaViewModel { + public readonly local = true; /** * Whether the video should be mirrored. */ @@ -453,6 +446,8 @@ export class LocalUserMediaViewModel extends BaseUserMediaViewModel { * A remote participant's user media. */ export class RemoteUserMediaViewModel extends BaseUserMediaViewModel { + public readonly local = false; + private readonly locallyMutedToggle = new Subject(); private readonly localVolumeAdjustment = new Subject(); private readonly localVolumeCommit = new Subject(); @@ -538,6 +533,7 @@ export class ScreenShareViewModel extends BaseMediaViewModel { participant: Observable, encryptionSystem: EncryptionSystem, livekitRoom: LivekitRoom, + public readonly local: boolean, ) { super( id,