signal-desktop/ts/state/selectors/accounts.ts
2021-06-17 10:15:10 -07:00

24 lines
667 B
TypeScript

// Copyright 2019-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { createSelector } from 'reselect';
import { StateType } from '../reducer';
import { AccountsStateType } from '../ducks/accounts';
export const getAccounts = (state: StateType): AccountsStateType =>
state.accounts;
export type AccountSelectorType = (identifier?: string) => boolean;
export const getAccountSelector = createSelector(
getAccounts,
(accounts: AccountsStateType): AccountSelectorType => {
return (identifier?: string) => {
if (!identifier) {
return false;
}
return accounts.accounts[identifier] || false;
};
}
);