From 256a65a119ce517e97dbf8d47b993fa0e6f819fd Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Wed, 20 Nov 2024 10:09:56 +0000 Subject: [PATCH] Simplify speaking observer --- src/state/MediaViewModel.ts | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/state/MediaViewModel.ts b/src/state/MediaViewModel.ts index 31232b74..32ab7747 100644 --- a/src/state/MediaViewModel.ts +++ b/src/state/MediaViewModel.ts @@ -335,19 +335,14 @@ abstract class BaseUserMediaViewModel extends BaseMediaViewModel { * Whether the participant is speaking. */ public readonly speaking = this.participant.pipe( - switchMap((p) => { - if (p) { - return observeParticipantEvents( - p, - ParticipantEvent.IsSpeakingChanged, - ).pipe( - map((p) => p.isSpeaking), - this.scope.state(), - ); - } else { - return of(false); - } - }), + switchMap((p) => + p + ? observeParticipantEvents(p, ParticipantEvent.IsSpeakingChanged).pipe( + map((p) => p.isSpeaking), + ) + : of(false), + ), + this.scope.state(), ); /**