From eed3e8e316135e002fb3ae3471f10741c3c34a87 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Fri, 11 Feb 2022 12:21:45 -0600 Subject: [PATCH] Disable "Call Again" if already on a call --- .../conversation/CallingNotification.tsx | 16 ++++++++++++---- ts/state/selectors/message.ts | 5 ++++- ts/util/callingNotification.ts | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ts/components/conversation/CallingNotification.tsx b/ts/components/conversation/CallingNotification.tsx index 932454c14..53cef45a2 100644 --- a/ts/components/conversation/CallingNotification.tsx +++ b/ts/components/conversation/CallingNotification.tsx @@ -114,6 +114,7 @@ function renderCallingNotificationButton( props: Readonly ): ReactNode { const { + activeCallConversationId, conversationId, i18n, nextItem, @@ -135,16 +136,23 @@ function renderCallingNotificationButton( buttonText = wasIncoming ? i18n('calling__call-back') : i18n('calling__call-again'); - onClick = () => { - startCallingLobby({ conversationId, isVideoCall: wasVideoCall }); - }; + if (activeCallConversationId) { + disabledTooltipText = i18n( + 'calling__call-notification__button__in-another-call-tooltip' + ); + onClick = noop; + } else { + onClick = () => { + startCallingLobby({ conversationId, isVideoCall: wasVideoCall }); + }; + } break; } case CallMode.Group: { if (props.ended) { return null; } - const { activeCallConversationId, deviceCount, maxDevices } = props; + const { deviceCount, maxDevices } = props; if (activeCallConversationId) { if (activeCallConversationId === conversationId) { buttonText = i18n('calling__return'); diff --git a/ts/state/selectors/message.ts b/ts/state/selectors/message.ts index 5f6f7c018..0d02a99fa 100644 --- a/ts/state/selectors/message.ts +++ b/ts/state/selectors/message.ts @@ -1124,12 +1124,15 @@ export function getPropsForCallHistory( throw new Error('getPropsForCallHistory: Missing callHistoryDetails'); } + const activeCallConversationId = activeCall?.conversationId; + switch (callHistoryDetails.callMode) { // Old messages weren't saved with a call mode. case undefined: case CallMode.Direct: return { ...callHistoryDetails, + activeCallConversationId, callMode: CallMode.Direct, }; case CallMode.Group: { @@ -1150,7 +1153,7 @@ export function getPropsForCallHistory( const deviceCount = call?.peekInfo?.deviceCount ?? 0; return { - activeCallConversationId: activeCall?.conversationId, + activeCallConversationId, callMode: CallMode.Group, conversationId, creator, diff --git a/ts/util/callingNotification.ts b/ts/util/callingNotification.ts index 08ddd9bc8..348e8f955 100644 --- a/ts/util/callingNotification.ts +++ b/ts/util/callingNotification.ts @@ -1,4 +1,4 @@ -// Copyright 2020-2021 Signal Messenger, LLC +// Copyright 2020-2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { LocalizerType } from '../types/Util'; @@ -8,6 +8,7 @@ import * as log from '../logging/log'; type DirectCallNotificationType = { callMode: CallMode.Direct; + activeCallConversationId?: string; wasIncoming: boolean; wasVideoCall: boolean; wasDeclined: boolean;