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

73 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2019-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2019-01-14 21:49:58 +00:00
import { createSelector } from 'reselect';
import type { LocalizerType, ThemeType } from '../../types/Util';
2021-10-26 22:59:08 +00:00
import type { UUIDStringType } from '../../types/UUID';
2019-01-14 21:49:58 +00:00
import type { StateType } from '../reducer';
import type { UserStateType } from '../ducks/user';
2019-01-14 21:49:58 +00:00
export const getUser = (state: StateType): UserStateType => state.user;
export const getUserNumber = createSelector(
getUser,
(state: UserStateType): string => state.ourNumber
);
export const getUserDeviceId = createSelector(
getUser,
(state: UserStateType): number => state.ourDeviceId
);
2019-01-14 21:49:58 +00:00
export const getRegionCode = createSelector(
getUser,
(state: UserStateType): string => state.regionCode
);
export const getUserConversationId = createSelector(
getUser,
(state: UserStateType): string => state.ourConversationId
);
export const getUserUuid = createSelector(
getUser,
2021-10-26 22:59:08 +00:00
(state: UserStateType): UUIDStringType => state.ourUuid
);
2019-01-14 21:49:58 +00:00
export const getIntl = createSelector(
getUser,
(state: UserStateType): LocalizerType => state.i18n
);
export const getInteractionMode = createSelector(
getUser,
(state: UserStateType) => state.interactionMode
);
export const getAttachmentsPath = createSelector(
getUser,
(state: UserStateType): string => state.attachmentsPath
);
export const getStickersPath = createSelector(
getUser,
(state: UserStateType): string => state.stickersPath
);
2019-11-07 21:36:16 +00:00
export const getPlatform = createSelector(
getUser,
(state: UserStateType): string => state.platform
);
export const getTempPath = createSelector(
getUser,
(state: UserStateType): string => state.tempPath
);
export const getTheme = createSelector(
getUser,
(state: UserStateType): ThemeType => state.theme
);