signal-desktop/ts/state/selectors/network.ts
2020-02-21 15:08:21 -08:00

21 lines
672 B
TypeScript

import { createSelector } from 'reselect';
import { StateType } from '../reducer';
import { NetworkStateType } from '../ducks/network';
import { isDone } from '../../util/registration';
const getNetwork = (state: StateType): NetworkStateType => state.network;
export const hasNetworkDialog = createSelector(
getNetwork,
isDone,
(
{ isOnline, socketStatus, withinConnectingGracePeriod }: NetworkStateType,
isRegistrationDone: boolean
): boolean =>
!isOnline ||
!isRegistrationDone ||
(socketStatus === WebSocket.CONNECTING && !withinConnectingGracePeriod) ||
socketStatus === WebSocket.CLOSED ||
socketStatus === WebSocket.CLOSING
);