Show 'join anyway' in verify dialog when joining call

This commit is contained in:
Scott Nonnenberg
2023-09-05 17:34:51 -07:00
committed by GitHub
parent b6ed789197
commit 507986db92
11 changed files with 85 additions and 46 deletions

View File

@@ -56,6 +56,7 @@ import type { ShowToastActionType } from './toast';
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import { useBoundActions } from '../../hooks/useBoundActions';
import { isAnybodyElseInGroupCall } from './callingHelpers';
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';
// State
@@ -1259,24 +1260,20 @@ function onOutgoingVideoCallInConversation(
log.info('onOutgoingVideoCallInConversation: about to start a video call');
// if it's a group call on an announcementsOnly group
// only allow join if the call has already been started (presumably by the admin)
const call = getOwn(getState().calling.callsByConversation, conversationId);
// Technically not necessary, but isAnybodyElseInGroupCall requires it
const ourAci = window.storage.user.getCheckedAci();
const isOngoingGroupCall =
call &&
ourAci &&
call.callMode === CallMode.Group &&
call.peekInfo &&
isAnybodyElseInGroupCall(call.peekInfo, ourAci);
// If it's a group call on an announcementsOnly group, only allow join if the call
// has already been started (presumably by the admin)
if (conversation.get('announcementsOnly') && !conversation.areWeAdmin()) {
const call = getOwn(
getState().calling.callsByConversation,
conversationId
);
// technically not necessary, but isAnybodyElseInGroupCall requires it
const ourAci = window.storage.user.getCheckedAci();
const isOngoingGroupCall =
call &&
ourAci &&
call.callMode === CallMode.Group &&
call.peekInfo &&
isAnybodyElseInGroupCall(call.peekInfo, ourAci);
if (!isOngoingGroupCall) {
dispatch({
type: SHOW_TOAST,
@@ -1288,7 +1285,11 @@ function onOutgoingVideoCallInConversation(
}
}
if (await isCallSafe(conversation.attributes)) {
const source = isOngoingGroupCall
? SafetyNumberChangeSource.JoinCall
: SafetyNumberChangeSource.InitiateCall;
if (await isCallSafe(conversation.attributes, source)) {
log.info(
'onOutgoingVideoCallInConversation: call is deemed "safe". Making call'
);
@@ -1323,10 +1324,13 @@ function onOutgoingAudioCallInConversation(
`onOutgoingAudioCallInConversation: Conversation ${conversation.idForLogging()} is not 1:1`
);
}
// Because audio calls are currently restricted to 1:1 conversations, this will always
// be a new call we are initiating.
const source = SafetyNumberChangeSource.InitiateCall;
log.info('onOutgoingAudioCallInConversation: about to start an audio call');
if (await isCallSafe(conversation.attributes)) {
if (await isCallSafe(conversation.attributes, source)) {
log.info(
'onOutgoingAudioCallInConversation: call is deemed "safe". Making call'
);

View File

@@ -45,12 +45,18 @@ export function SmartSendAnywayDialog(): JSX.Element {
let confirmText: string | undefined = i18n(
'icu:safetyNumberChangeDialog__pending-messages'
);
if (safetyNumberChangedBlockingData?.source) {
confirmText =
safetyNumberChangedBlockingData?.source ===
SafetyNumberChangeSource.Calling
? i18n('icu:callAnyway')
: undefined;
if (
safetyNumberChangedBlockingData?.source ===
SafetyNumberChangeSource.InitiateCall
) {
confirmText = i18n('icu:callAnyway');
} else if (
safetyNumberChangedBlockingData?.source ===
SafetyNumberChangeSource.JoinCall
) {
confirmText = i18n('icu:joinAnyway');
} else {
confirmText = undefined;
}
return (

View File

@@ -149,7 +149,11 @@ export function SmartTimelineItem(props: ExternalProps): JSX.Element {
const { viewStory } = useStoriesActions();
const { returnToActiveCall, startCallingLobby } = useCallingActions();
const {
onOutgoingAudioCallInConversation,
onOutgoingVideoCallInConversation,
returnToActiveCall,
} = useCallingActions();
return (
<TimelineItem
@@ -186,6 +190,8 @@ export function SmartTimelineItem(props: ExternalProps): JSX.Element {
pushPanelForConversation={pushPanelForConversation}
reactToMessage={reactToMessage}
copyMessageText={copyMessageText}
onOutgoingAudioCallInConversation={onOutgoingAudioCallInConversation}
onOutgoingVideoCallInConversation={onOutgoingVideoCallInConversation}
retryDeleteForEveryone={retryDeleteForEveryone}
retryMessageSend={retryMessageSend}
returnToActiveCall={returnToActiveCall}
@@ -201,7 +207,6 @@ export function SmartTimelineItem(props: ExternalProps): JSX.Element {
showLightbox={showLightbox}
showLightboxForViewOnceMedia={showLightboxForViewOnceMedia}
showSpoiler={showSpoiler}
startCallingLobby={startCallingLobby}
startConversation={startConversation}
toggleDeleteMessagesModal={toggleDeleteMessagesModal}
toggleForwardMessagesModal={toggleForwardMessagesModal}