2021-06-08 21:31:35 +00:00
|
|
|
// Copyright 2019-2021 Signal Messenger, LLC
|
2020-12-04 20:41:40 +00:00
|
|
|
// 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';
|
|
|
|
|
2020-12-04 20:41:40 +00:00
|
|
|
import { StateType } from '../reducer';
|
|
|
|
import { ItemsStateType } from '../ducks/items';
|
2021-06-02 21:05:09 +00:00
|
|
|
import {
|
|
|
|
ConversationColorType,
|
|
|
|
CustomColorType,
|
2021-06-08 21:31:35 +00:00
|
|
|
DEFAULT_CONVERSATION_COLOR,
|
2021-06-02 21:05:09 +00:00
|
|
|
} from '../../types/Colors';
|
2020-12-04 20:41:40 +00:00
|
|
|
|
|
|
|
export const getItems = (state: StateType): ItemsStateType => state.items;
|
|
|
|
|
|
|
|
export const getUserAgent = createSelector(
|
|
|
|
getItems,
|
|
|
|
(state: ItemsStateType): string => state.userAgent as string
|
|
|
|
);
|
|
|
|
|
2021-06-17 17:15:10 +00:00
|
|
|
export const getReadReceiptSetting = createSelector(
|
|
|
|
getItems,
|
|
|
|
(state: ItemsStateType): boolean => Boolean(state['read-receipt-setting'])
|
|
|
|
);
|
|
|
|
|
2020-12-04 20:41:40 +00:00
|
|
|
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;
|
|
|
|
};
|
2021-06-08 21:31:35 +00:00
|
|
|
} => state.defaultConversationColor ?? DEFAULT_CONVERSATION_COLOR
|
2021-06-02 21:05:09 +00:00
|
|
|
);
|