2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-06-26 00:08:58 +00:00
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type {
|
2020-06-26 00:08:58 +00:00
|
|
|
SafetyNumberContactType,
|
|
|
|
SafetyNumberStateType,
|
|
|
|
} from '../ducks/safetyNumber';
|
|
|
|
|
|
|
|
const getSafetyNumber = (state: StateType): SafetyNumberStateType =>
|
|
|
|
state.safetyNumber;
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
contactID: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const getContactID = (_: StateType, props: Props): string => props.contactID;
|
|
|
|
|
|
|
|
export const getContactSafetyNumber = createSelector(
|
|
|
|
[getSafetyNumber, getContactID],
|
|
|
|
(
|
|
|
|
{ contacts }: SafetyNumberStateType,
|
|
|
|
contactID: string
|
2024-03-14 19:35:03 +00:00
|
|
|
): SafetyNumberContactType | void => contacts[contactID]
|
2020-06-26 00:08:58 +00:00
|
|
|
);
|
2024-03-15 14:38:26 +00:00
|
|
|
|
|
|
|
export const getContactSafetyNumberSelector = createSelector(
|
|
|
|
[getSafetyNumber],
|
|
|
|
({ contacts }) => {
|
|
|
|
return (contactId: string) => {
|
|
|
|
return contacts[contactId];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|