2021-06-01 23:30:25 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
2021-06-01 23:30:25 +00:00
|
|
|
import { missingCaseError } from './missingCaseError';
|
|
|
|
|
|
|
|
export function isConversationNameKnown(
|
|
|
|
conversation: Readonly<
|
|
|
|
Pick<ConversationType, 'e164' | 'name' | 'profileName' | 'type'>
|
|
|
|
>
|
|
|
|
): boolean {
|
|
|
|
switch (conversation.type) {
|
|
|
|
case 'direct':
|
|
|
|
return Boolean(
|
|
|
|
conversation.name || conversation.profileName || conversation.e164
|
|
|
|
);
|
|
|
|
case 'group':
|
|
|
|
return Boolean(conversation.name);
|
|
|
|
default:
|
|
|
|
throw missingCaseError(conversation.type);
|
|
|
|
}
|
|
|
|
}
|