signal-desktop/ts/state/selectors/items.ts

46 lines
1.2 KiB
TypeScript
Raw Normal View History

// Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { createSelector } from 'reselect';
2021-06-01 20:45:43 +00:00
import { ITEM_NAME as UNIVERSAL_EXPIRE_TIMER_ITEM } from '../../util/universalExpireTimer';
import { StateType } from '../reducer';
import { ItemsStateType } from '../ducks/items';
2021-06-02 21:05:09 +00:00
import {
ConversationColorType,
CustomColorType,
DEFAULT_CONVERSATION_COLOR,
2021-06-02 21:05:09 +00:00
} from '../../types/Colors';
export const getItems = (state: StateType): ItemsStateType => state.items;
export const getUserAgent = createSelector(
getItems,
(state: ItemsStateType): string => state.userAgent as string
);
export const getPinnedConversationIds = createSelector(
getItems,
(state: ItemsStateType): Array<string> =>
(state.pinnedConversationIds || []) as Array<string>
);
2021-06-01 20:45:43 +00:00
export const getUniversalExpireTimer = createSelector(
getItems,
(state: ItemsStateType): number => state[UNIVERSAL_EXPIRE_TIMER_ITEM] || 0
);
2021-06-02 21:05:09 +00:00
export const getDefaultConversationColor = createSelector(
getItems,
(
state: ItemsStateType
): {
color: ConversationColorType;
customColorData?: {
id: string;
value: CustomColorType;
};
} => state.defaultConversationColor ?? DEFAULT_CONVERSATION_COLOR
2021-06-02 21:05:09 +00:00
);