2021-08-06 00:17:05 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { AvatarDataType } from '../types/Avatar';
|
|
|
|
import { getDefaultAvatars } from '../types/Avatar';
|
2021-08-06 00:17:05 +00:00
|
|
|
import { isDirectConversation } from './whatTypeOfConversation';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationAttributesType } from '../model-types.d';
|
2021-08-06 00:17:05 +00:00
|
|
|
|
|
|
|
export function getAvatarData(
|
|
|
|
conversationAttrs: Pick<ConversationAttributesType, 'avatars' | 'type'>
|
2022-12-22 00:07:02 +00:00
|
|
|
): ReadonlyArray<AvatarDataType> {
|
2021-08-06 00:17:05 +00:00
|
|
|
const { avatars } = conversationAttrs;
|
|
|
|
|
|
|
|
if (avatars && avatars.length) {
|
|
|
|
return avatars;
|
|
|
|
}
|
|
|
|
|
|
|
|
const isGroup = !isDirectConversation(conversationAttrs);
|
|
|
|
|
|
|
|
return getDefaultAvatars(isGroup);
|
|
|
|
}
|