Fix default conversation color to use state
This commit is contained in:
parent
f3eee779a0
commit
cf28e2dc2c
6 changed files with 57 additions and 16 deletions
|
@ -61,6 +61,7 @@ import { getMentionsRegex } from '../../types/Message';
|
||||||
import { SignalService as Proto } from '../../protobuf';
|
import { SignalService as Proto } from '../../protobuf';
|
||||||
import type { AttachmentType } from '../../types/Attachment';
|
import type { AttachmentType } from '../../types/Attachment';
|
||||||
import { isVoiceMessage, canBeDownloaded } from '../../types/Attachment';
|
import { isVoiceMessage, canBeDownloaded } from '../../types/Attachment';
|
||||||
|
import type { DefaultConversationColorType } from '../../types/Colors';
|
||||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||||
|
|
||||||
import type { CallingNotificationType } from '../../util/callingNotification';
|
import type { CallingNotificationType } from '../../util/callingNotification';
|
||||||
|
@ -73,6 +74,7 @@ import { strictAssert } from '../../util/assert';
|
||||||
import { canEditMessage } from '../../util/canEditMessage';
|
import { canEditMessage } from '../../util/canEditMessage';
|
||||||
|
|
||||||
import { getAccountSelector } from './accounts';
|
import { getAccountSelector } from './accounts';
|
||||||
|
import { getDefaultConversationColor } from './items';
|
||||||
import {
|
import {
|
||||||
getContactNameColorSelector,
|
getContactNameColorSelector,
|
||||||
getConversationSelector,
|
getConversationSelector,
|
||||||
|
@ -176,6 +178,7 @@ export type GetPropsForBubbleOptions = Readonly<{
|
||||||
activeCall?: CallStateType;
|
activeCall?: CallStateType;
|
||||||
accountSelector: AccountSelectorType;
|
accountSelector: AccountSelectorType;
|
||||||
contactNameColorSelector: ContactNameColorSelectorType;
|
contactNameColorSelector: ContactNameColorSelectorType;
|
||||||
|
defaultConversationColor: DefaultConversationColorType;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export function hasErrors(
|
export function hasErrors(
|
||||||
|
@ -474,9 +477,11 @@ const getPropsForStoryReplyContext = (
|
||||||
{
|
{
|
||||||
conversationSelector,
|
conversationSelector,
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
|
defaultConversationColor,
|
||||||
}: {
|
}: {
|
||||||
conversationSelector: GetConversationByIdType;
|
conversationSelector: GetConversationByIdType;
|
||||||
ourConversationId?: string;
|
ourConversationId?: string;
|
||||||
|
defaultConversationColor: DefaultConversationColorType;
|
||||||
}
|
}
|
||||||
): PropsData['storyReplyContext'] => {
|
): PropsData['storyReplyContext'] => {
|
||||||
const { storyReaction, storyReplyContext } = message;
|
const { storyReaction, storyReplyContext } = message;
|
||||||
|
@ -491,8 +496,10 @@ const getPropsForStoryReplyContext = (
|
||||||
|
|
||||||
const conversation = getConversation(message, conversationSelector);
|
const conversation = getConversation(message, conversationSelector);
|
||||||
|
|
||||||
const { conversationColor, customColor } =
|
const { conversationColor, customColor } = getConversationColorAttributes(
|
||||||
getConversationColorAttributes(conversation);
|
conversation,
|
||||||
|
defaultConversationColor
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
authorTitle,
|
authorTitle,
|
||||||
|
@ -515,9 +522,11 @@ export const getPropsForQuote = (
|
||||||
{
|
{
|
||||||
conversationSelector,
|
conversationSelector,
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
|
defaultConversationColor,
|
||||||
}: {
|
}: {
|
||||||
conversationSelector: GetConversationByIdType;
|
conversationSelector: GetConversationByIdType;
|
||||||
ourConversationId?: string;
|
ourConversationId?: string;
|
||||||
|
defaultConversationColor: DefaultConversationColorType;
|
||||||
}
|
}
|
||||||
): PropsData['quote'] => {
|
): PropsData['quote'] => {
|
||||||
const { quote } = message;
|
const { quote } = message;
|
||||||
|
@ -548,8 +557,10 @@ export const getPropsForQuote = (
|
||||||
const firstAttachment = quote.attachments && quote.attachments[0];
|
const firstAttachment = quote.attachments && quote.attachments[0];
|
||||||
const conversation = getConversation(message, conversationSelector);
|
const conversation = getConversation(message, conversationSelector);
|
||||||
|
|
||||||
const { conversationColor, customColor } =
|
const { conversationColor, customColor } = getConversationColorAttributes(
|
||||||
getConversationColorAttributes(conversation);
|
conversation,
|
||||||
|
defaultConversationColor
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
authorId,
|
authorId,
|
||||||
|
@ -587,6 +598,7 @@ export type GetPropsForMessageOptions = Pick<
|
||||||
| 'regionCode'
|
| 'regionCode'
|
||||||
| 'accountSelector'
|
| 'accountSelector'
|
||||||
| 'contactNameColorSelector'
|
| 'contactNameColorSelector'
|
||||||
|
| 'defaultConversationColor'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
function getTextAttachment(
|
function getTextAttachment(
|
||||||
|
@ -681,6 +693,7 @@ export const getPropsForMessage = (
|
||||||
targetedMessageCounter,
|
targetedMessageCounter,
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
contactNameColorSelector,
|
contactNameColorSelector,
|
||||||
|
defaultConversationColor,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const { expireTimer, expirationStartTimestamp, conversationId } = message;
|
const { expireTimer, expirationStartTimestamp, conversationId } = message;
|
||||||
|
@ -710,8 +723,10 @@ export const getPropsForMessage = (
|
||||||
});
|
});
|
||||||
const contactNameColor = contactNameColorSelector(conversationId, authorId);
|
const contactNameColor = contactNameColorSelector(conversationId, authorId);
|
||||||
|
|
||||||
const { conversationColor, customColor } =
|
const { conversationColor, customColor } = getConversationColorAttributes(
|
||||||
getConversationColorAttributes(conversation);
|
conversation,
|
||||||
|
defaultConversationColor
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attachments,
|
attachments,
|
||||||
|
@ -785,6 +800,7 @@ export const getMessagePropsSelector = createSelector(
|
||||||
getContactNameColorSelector,
|
getContactNameColorSelector,
|
||||||
getTargetedMessage,
|
getTargetedMessage,
|
||||||
getSelectedMessageIds,
|
getSelectedMessageIds,
|
||||||
|
getDefaultConversationColor,
|
||||||
(
|
(
|
||||||
conversationSelector,
|
conversationSelector,
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
|
@ -795,7 +811,8 @@ export const getMessagePropsSelector = createSelector(
|
||||||
accountSelector,
|
accountSelector,
|
||||||
contactNameColorSelector,
|
contactNameColorSelector,
|
||||||
targetedMessage,
|
targetedMessage,
|
||||||
selectedMessageIds
|
selectedMessageIds,
|
||||||
|
defaultConversationColor
|
||||||
) =>
|
) =>
|
||||||
(message: MessageWithUIFieldsType) => {
|
(message: MessageWithUIFieldsType) => {
|
||||||
return getPropsForMessage(message, {
|
return getPropsForMessage(message, {
|
||||||
|
@ -810,6 +827,7 @@ export const getMessagePropsSelector = createSelector(
|
||||||
targetedMessageCounter: targetedMessage?.counter,
|
targetedMessageCounter: targetedMessage?.counter,
|
||||||
targetedMessageId: targetedMessage?.id,
|
targetedMessageId: targetedMessage?.id,
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
|
defaultConversationColor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1919,6 +1937,7 @@ export const getMessageDetails = createSelector(
|
||||||
getUserConversationId,
|
getUserConversationId,
|
||||||
getUserNumber,
|
getUserNumber,
|
||||||
getSelectedMessageIds,
|
getSelectedMessageIds,
|
||||||
|
getDefaultConversationColor,
|
||||||
(
|
(
|
||||||
accountSelector,
|
accountSelector,
|
||||||
contactNameColorSelector,
|
contactNameColorSelector,
|
||||||
|
@ -1930,7 +1949,8 @@ export const getMessageDetails = createSelector(
|
||||||
ourPni,
|
ourPni,
|
||||||
ourConversationId,
|
ourConversationId,
|
||||||
ourNumber,
|
ourNumber,
|
||||||
selectedMessageIds
|
selectedMessageIds,
|
||||||
|
defaultConversationColor
|
||||||
): SmartMessageDetailPropsType | undefined => {
|
): SmartMessageDetailPropsType | undefined => {
|
||||||
if (!message || !ourConversationId) {
|
if (!message || !ourConversationId) {
|
||||||
return;
|
return;
|
||||||
|
@ -2066,6 +2086,7 @@ export const getMessageDetails = createSelector(
|
||||||
ourNumber,
|
ourNumber,
|
||||||
regionCode,
|
regionCode,
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
|
defaultConversationColor,
|
||||||
}),
|
}),
|
||||||
receivedAt: Number(message.received_at_ms || message.received_at),
|
receivedAt: Number(message.received_at_ms || message.received_at),
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
getUserACI,
|
getUserACI,
|
||||||
getUserPNI,
|
getUserPNI,
|
||||||
} from './user';
|
} from './user';
|
||||||
|
import { getDefaultConversationColor } from './items';
|
||||||
import { getActiveCall, getCallSelector } from './calling';
|
import { getActiveCall, getCallSelector } from './calling';
|
||||||
import { getPropsForBubble } from './message';
|
import { getPropsForBubble } from './message';
|
||||||
import { getCallHistorySelector } from './callHistory';
|
import { getCallHistorySelector } from './callHistory';
|
||||||
|
@ -51,6 +52,7 @@ export const getTimelineItem = (
|
||||||
const accountSelector = getAccountSelector(state);
|
const accountSelector = getAccountSelector(state);
|
||||||
const contactNameColorSelector = getContactNameColorSelector(state);
|
const contactNameColorSelector = getContactNameColorSelector(state);
|
||||||
const selectedMessageIds = getSelectedMessageIds(state);
|
const selectedMessageIds = getSelectedMessageIds(state);
|
||||||
|
const defaultConversationColor = getDefaultConversationColor(state);
|
||||||
|
|
||||||
return getPropsForBubble(message, {
|
return getPropsForBubble(message, {
|
||||||
conversationSelector,
|
conversationSelector,
|
||||||
|
@ -67,5 +69,6 @@ export const getTimelineItem = (
|
||||||
activeCall,
|
activeCall,
|
||||||
accountSelector,
|
accountSelector,
|
||||||
selectedMessageIds,
|
selectedMessageIds,
|
||||||
|
defaultConversationColor,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
getConversationsWithCustomColorSelector,
|
getConversationsWithCustomColorSelector,
|
||||||
} from '../selectors/conversations';
|
} from '../selectors/conversations';
|
||||||
import { getIntl } from '../selectors/user';
|
import { getIntl } from '../selectors/user';
|
||||||
|
import { getDefaultConversationColor } from '../selectors/items';
|
||||||
import { getConversationColorAttributes } from '../../util/getConversationColorAttributes';
|
import { getConversationColorAttributes } from '../../util/getConversationColorAttributes';
|
||||||
|
|
||||||
export type SmartChatColorPickerProps = {
|
export type SmartChatColorPickerProps = {
|
||||||
|
@ -25,7 +26,11 @@ const mapStateToProps = (
|
||||||
const conversation = props.conversationId
|
const conversation = props.conversationId
|
||||||
? getConversationSelector(state)(props.conversationId)
|
? getConversationSelector(state)(props.conversationId)
|
||||||
: {};
|
: {};
|
||||||
const colorValues = getConversationColorAttributes(conversation);
|
const defaultConversationColor = getDefaultConversationColor(state);
|
||||||
|
const colorValues = getConversationColorAttributes(
|
||||||
|
conversation,
|
||||||
|
defaultConversationColor
|
||||||
|
);
|
||||||
|
|
||||||
const { customColors } = state.items;
|
const { customColors } = state.items;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,11 @@ import {
|
||||||
getTheme,
|
getTheme,
|
||||||
getUserConversationId,
|
getUserConversationId,
|
||||||
} from '../selectors/user';
|
} from '../selectors/user';
|
||||||
import { getEmojiSkinTone, getTextFormattingEnabled } from '../selectors/items';
|
import {
|
||||||
|
getDefaultConversationColor,
|
||||||
|
getEmojiSkinTone,
|
||||||
|
getTextFormattingEnabled,
|
||||||
|
} from '../selectors/items';
|
||||||
import {
|
import {
|
||||||
getConversationSelector,
|
getConversationSelector,
|
||||||
getGroupAdminsSelector,
|
getGroupAdminsSelector,
|
||||||
|
@ -169,6 +173,7 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
||||||
? getPropsForQuote(quotedMessage, {
|
? getPropsForQuote(quotedMessage, {
|
||||||
conversationSelector,
|
conversationSelector,
|
||||||
ourConversationId: getUserConversationId(state),
|
ourConversationId: getUserConversationId(state),
|
||||||
|
defaultConversationColor: getDefaultConversationColor(state),
|
||||||
})
|
})
|
||||||
: undefined,
|
: undefined,
|
||||||
quotedMessageAuthorAci: quotedMessage?.quote?.authorAci,
|
quotedMessageAuthorAci: quotedMessage?.quote?.authorAci,
|
||||||
|
|
|
@ -16,7 +16,10 @@ import {
|
||||||
} from '../selectors/conversations';
|
} from '../selectors/conversations';
|
||||||
import { getGroupMemberships } from '../../util/getGroupMemberships';
|
import { getGroupMemberships } from '../../util/getGroupMemberships';
|
||||||
import { getActiveCallState } from '../selectors/calling';
|
import { getActiveCallState } from '../selectors/calling';
|
||||||
import { getAreWeASubscriber } from '../selectors/items';
|
import {
|
||||||
|
getAreWeASubscriber,
|
||||||
|
getDefaultConversationColor,
|
||||||
|
} from '../selectors/items';
|
||||||
import { getIntl, getTheme } from '../selectors/user';
|
import { getIntl, getTheme } from '../selectors/user';
|
||||||
import {
|
import {
|
||||||
getBadgesSelector,
|
getBadgesSelector,
|
||||||
|
@ -82,6 +85,7 @@ const mapStateToProps = (
|
||||||
);
|
);
|
||||||
|
|
||||||
const badges = getBadgesSelector(state)(conversation.badges);
|
const badges = getBadgesSelector(state)(conversation.badges);
|
||||||
|
const defaultConversationColor = getDefaultConversationColor(state);
|
||||||
|
|
||||||
const groupsInCommon =
|
const groupsInCommon =
|
||||||
conversation.type === 'direct'
|
conversation.type === 'direct'
|
||||||
|
@ -107,7 +111,7 @@ const mapStateToProps = (
|
||||||
canAddNewMembers,
|
canAddNewMembers,
|
||||||
conversation: {
|
conversation: {
|
||||||
...conversation,
|
...conversation,
|
||||||
...getConversationColorAttributes(conversation),
|
...getConversationColorAttributes(conversation, defaultConversationColor),
|
||||||
},
|
},
|
||||||
getPreferredBadge: getPreferredBadgeSelector(state),
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
||||||
hasActiveCall: Boolean(getActiveCallState(state)),
|
hasActiveCall: Boolean(getActiveCallState(state)),
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
import type {
|
||||||
|
ConversationColorType,
|
||||||
|
CustomColorType,
|
||||||
|
DefaultConversationColorType,
|
||||||
|
} from '../types/Colors';
|
||||||
import type { ConversationType } from '../state/ducks/conversations';
|
import type { ConversationType } from '../state/ducks/conversations';
|
||||||
|
|
||||||
export function getConversationColorAttributes(
|
export function getConversationColorAttributes(
|
||||||
conversationColors: Pick<
|
conversationColors: Pick<
|
||||||
ConversationType,
|
ConversationType,
|
||||||
'conversationColor' | 'customColorId' | 'customColor'
|
'conversationColor' | 'customColorId' | 'customColor'
|
||||||
>
|
>,
|
||||||
|
defaultConversationColor: DefaultConversationColorType
|
||||||
): {
|
): {
|
||||||
conversationColor: ConversationColorType;
|
conversationColor: ConversationColorType;
|
||||||
customColor: CustomColorType | undefined;
|
customColor: CustomColorType | undefined;
|
||||||
customColorId: string | undefined;
|
customColorId: string | undefined;
|
||||||
} {
|
} {
|
||||||
const defaultConversationColor = window.Events.getDefaultConversationColor();
|
|
||||||
|
|
||||||
const conversationColor =
|
const conversationColor =
|
||||||
conversationColors.conversationColor || defaultConversationColor.color;
|
conversationColors.conversationColor || defaultConversationColor.color;
|
||||||
const customColor =
|
const customColor =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue