ConversationView: Move call/mute functions into redux

This commit is contained in:
Scott Nonnenberg 2022-12-06 09:31:44 -08:00 committed by GitHub
parent 8fe51cc854
commit 92a512a16d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 353 additions and 287 deletions

38
ts/util/isCallSafe.ts Normal file
View file

@ -0,0 +1,38 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ConversationAttributesType } from '../model-types';
import type { RecipientsByConversation } from '../state/ducks/stories';
import * as log from '../logging/log';
import { SafetyNumberChangeSource } from '../components/SafetyNumberChangeDialog';
import { blockSendUntilConversationsAreVerified } from './blockSendUntilConversationsAreVerified';
import { getConversationMembers } from './getConversationMembers';
import { UUID } from '../types/UUID';
import { isNotNil } from './isNotNil';
export async function isCallSafe(
attributes: ConversationAttributesType
): Promise<boolean> {
const recipientsByConversation: RecipientsByConversation = {
[attributes.id]: {
uuids: getConversationMembers(attributes)
.map(member =>
member.uuid ? UUID.checkedLookup(member.uuid).toString() : undefined
)
.filter(isNotNil),
},
};
const callAnyway = await blockSendUntilConversationsAreVerified(
recipientsByConversation,
SafetyNumberChangeSource.Calling
);
if (!callAnyway) {
log.info('Safety number change dialog not accepted, new call not allowed.');
return false;
}
return true;
}