Fix default conversation color overrides
This commit is contained in:
parent
4a011b71d9
commit
2136c5311b
4 changed files with 55 additions and 23 deletions
37
ts/util/getConversationColorAttributes.ts
Normal file
37
ts/util/getConversationColorAttributes.ts
Normal 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,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue