Fix default conversation color overrides

This commit is contained in:
Josh Perez 2021-12-03 21:10:03 -05:00 committed by GitHub
parent 4a011b71d9
commit 2136c5311b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 23 deletions

View file

@ -0,0 +1,37 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ConversationColorType, CustomColorType } from '../types/Colors';
import type { ConversationType } from '../state/ducks/conversations';
export function getConversationColorAttributes(
conversationColors: Pick<
ConversationType,
'conversationColor' | 'customColorId' | 'customColor'
>
): {
conversationColor: ConversationColorType;
customColor: CustomColorType | undefined;
customColorId: string | undefined;
} {
const defaultConversationColor = window.Events.getDefaultConversationColor();
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,
};
}