ConversationView: Move call/mute functions into redux
This commit is contained in:
parent
8fe51cc854
commit
92a512a16d
17 changed files with 353 additions and 287 deletions
38
ts/util/isCallSafe.ts
Normal file
38
ts/util/isCallSafe.ts
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue