signal-desktop/ts/state/selectors/network.ts
2020-04-29 17:42:41 -07:00

21 lines
679 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 =>
isRegistrationDone &&
(!isOnline ||
(socketStatus === WebSocket.CONNECTING && !withinConnectingGracePeriod) ||
socketStatus === WebSocket.CLOSED ||
socketStatus === WebSocket.CLOSING)
);