Conversation: Prevent getProps errors on initial link

Co-authored-by: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com>
This commit is contained in:
Scott Nonnenberg 2021-06-08 14:31:35 -07:00 committed by GitHub
parent e4a632f601
commit f226822dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 36 deletions

View file

@ -26,6 +26,8 @@ import {
AvatarColorType,
ConversationColorType,
CustomColorType,
DefaultConversationColorType,
DEFAULT_CONVERSATION_COLOR,
} from '../../types/Colors';
import { ConversationAttributesType } from '../../model-types.d';
import { BodyRangeType } from '../../types/Util';
@ -394,13 +396,7 @@ type CustomColorRemovedActionType = {
type: typeof CUSTOM_COLOR_REMOVED;
payload: {
colorId: string;
defaultConversationColor: {
color: ConversationColorType;
customColorData?: {
id: string;
value: CustomColorType;
};
};
defaultConversationColor: DefaultConversationColorType;
};
};
type SetPreJoinConversationActionType = {
@ -765,7 +761,8 @@ function removeCustomColorOnConversations(
}
const defaultConversationColor = window.storage.get(
'defaultConversationColor'
'defaultConversationColor',
DEFAULT_CONVERSATION_COLOR
);
dispatch({
@ -800,7 +797,8 @@ function resetAllChatColors(): ThunkAction<
});
const defaultConversationColor = window.storage.get(
'defaultConversationColor'
'defaultConversationColor',
DEFAULT_CONVERSATION_COLOR
);
dispatch({

View file

@ -1,4 +1,4 @@
// Copyright 2019-2020 Signal Messenger, LLC
// Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { omit } from 'lodash';
@ -11,6 +11,7 @@ import {
ConversationColors,
ConversationColorType,
CustomColorType,
DefaultConversationColorType,
} from '../../types/Colors';
import { reloadSelectedConversation } from '../../shims/reloadSelectedConversation';
@ -22,13 +23,7 @@ export type ItemsStateType = {
readonly [key: string]: unknown;
// This property should always be set and this is ensured in background.ts
readonly defaultConversationColor?: {
color: ConversationColorType;
customColorData?: {
id: string;
value: CustomColorType;
};
};
readonly defaultConversationColor?: DefaultConversationColorType;
readonly customColors?: {
readonly colors: Record<string, CustomColorType>;

View file

@ -1,4 +1,4 @@
// Copyright 2019-2020 Signal Messenger, LLC
// Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { createSelector } from 'reselect';
@ -8,9 +8,9 @@ import { ITEM_NAME as UNIVERSAL_EXPIRE_TIMER_ITEM } from '../../util/universalEx
import { StateType } from '../reducer';
import { ItemsStateType } from '../ducks/items';
import {
ConversationColors,
ConversationColorType,
CustomColorType,
DEFAULT_CONVERSATION_COLOR,
} from '../../types/Colors';
export const getItems = (state: StateType): ItemsStateType => state.items;
@ -41,5 +41,5 @@ export const getDefaultConversationColor = createSelector(
id: string;
value: CustomColorType;
};
} => state.defaultConversationColor ?? { color: ConversationColors[0] }
} => state.defaultConversationColor ?? DEFAULT_CONVERSATION_COLOR
);