From 79e4a95b13bded8accd3a6a4b7e6002ed246fde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Wed, 4 Aug 2021 16:25:44 +0200 Subject: [PATCH] Move stuff out of if statement for better readability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/CallHandler.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/CallHandler.tsx b/src/CallHandler.tsx index d4a29a11b9..8d862498d2 100644 --- a/src/CallHandler.tsx +++ b/src/CallHandler.tsx @@ -481,15 +481,14 @@ export default class CallHandler extends EventEmitter { const incomingCallPushRule = ( new PushProcessor(MatrixClientPeg.get()).getPushRuleById(RuleId.IncomingCall) as IPushRule ); + const pushRuleEnabled = incomingCallPushRule?.enabled; + const tweakSetToRing = incomingCallPushRule.actions.some((action: Tweaks) => ( + action.set_tweak === TweakName.Sound && + action.value === "ring" + )); switch (newState) { case CallState.Ringing: - if ( - incomingCallPushRule?.enabled && - incomingCallPushRule.actions.some((a: Tweaks) => ( - a.set_tweak === TweakName.Sound && - a.value === "ring" - )) - ) { + if (pushRuleEnabled && tweakSetToRing) { this.play(AudioID.Ring); } else { this.silenceCall(call.callId);