2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-02-12 21:30:58 +00:00
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type { NetworkStateType } from '../ducks/network';
|
2020-02-21 23:08:21 +00:00
|
|
|
import { isDone } from '../../util/registration';
|
2020-02-12 21:30:58 +00:00
|
|
|
|
|
|
|
const getNetwork = (state: StateType): NetworkStateType => state.network;
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const getNetworkIsOnline = createSelector(
|
|
|
|
getNetwork,
|
|
|
|
({ isOnline }) => isOnline
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getNetworkIsOutage = createSelector(
|
|
|
|
getNetwork,
|
|
|
|
({ isOutage }) => isOutage
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getNetworkSocketStatus = createSelector(
|
|
|
|
getNetwork,
|
|
|
|
({ socketStatus }) => socketStatus
|
|
|
|
);
|
|
|
|
|
2020-02-12 21:30:58 +00:00
|
|
|
export const hasNetworkDialog = createSelector(
|
|
|
|
getNetwork,
|
|
|
|
isDone,
|
|
|
|
(
|
2024-03-18 21:48:00 +00:00
|
|
|
{ isOnline, isOutage }: NetworkStateType,
|
2020-02-12 21:30:58 +00:00
|
|
|
isRegistrationDone: boolean
|
2024-03-18 21:48:00 +00:00
|
|
|
): boolean => isRegistrationDone && (!isOnline || isOutage)
|
2020-02-12 21:30:58 +00:00
|
|
|
);
|
2021-05-06 00:09:29 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const getChallengeStatus = createSelector(
|
|
|
|
getNetwork,
|
|
|
|
({ challengeStatus }) => challengeStatus
|
|
|
|
);
|
|
|
|
|
2021-05-06 00:09:29 +00:00
|
|
|
export const isChallengePending = createSelector(
|
|
|
|
getNetwork,
|
|
|
|
({ challengeStatus }) => challengeStatus === 'pending'
|
|
|
|
);
|