2021-12-04 02:10:03 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-09-01 17:03:44 +00:00
|
|
|
import type {
|
|
|
|
ConversationColorType,
|
|
|
|
CustomColorType,
|
|
|
|
DefaultConversationColorType,
|
|
|
|
} from '../types/Colors';
|
2021-12-04 02:10:03 +00:00
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
|
|
|
|
|
|
|
export function getConversationColorAttributes(
|
|
|
|
conversationColors: Pick<
|
|
|
|
ConversationType,
|
|
|
|
'conversationColor' | 'customColorId' | 'customColor'
|
2023-09-01 17:03:44 +00:00
|
|
|
>,
|
|
|
|
defaultConversationColor: DefaultConversationColorType
|
2021-12-04 02:10:03 +00:00
|
|
|
): {
|
|
|
|
conversationColor: ConversationColorType;
|
|
|
|
customColor: CustomColorType | undefined;
|
|
|
|
customColorId: string | undefined;
|
|
|
|
} {
|
|
|
|
const conversationColor =
|
|
|
|
conversationColors.conversationColor || defaultConversationColor.color;
|
|
|
|
const customColor =
|
|
|
|
conversationColor !== 'custom'
|
|
|
|
? undefined
|
|
|
|
: conversationColors.customColor ||
|
|
|
|
defaultConversationColor.customColorData?.value;
|
|
|
|
const customColorId =
|
|
|
|
conversationColor !== 'custom'
|
|
|
|
? undefined
|
|
|
|
: conversationColors.customColorId ||
|
|
|
|
defaultConversationColor.customColorData?.id;
|
|
|
|
|
|
|
|
return {
|
|
|
|
conversationColor,
|
|
|
|
customColor,
|
|
|
|
customColorId,
|
|
|
|
};
|
|
|
|
}
|