From 752cd75c5467335c6f3d32b733aa3d43a1a8c38a Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Mon, 27 Apr 2020 18:36:49 -0400 Subject: [PATCH] Make RelinkDialog supersede the NetworkDialog --- ts/components/LeftPane.tsx | 2 +- ts/components/RelinkDialog.stories.tsx | 17 ++--------------- ts/components/RelinkDialog.tsx | 4 +--- ts/state/selectors/network.ts | 10 +++++----- ts/state/smart/RelinkDialog.tsx | 2 -- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index f14c01f90..33d09dd14 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -393,9 +393,9 @@ export class LeftPane extends React.Component { {showArchived ? this.renderArchivedHeader() : renderMainHeader()} {renderExpiredBuildDialog()} + {renderRelinkDialog()} {renderNetworkStatus()} {renderUpdateDialog()} - {renderRelinkDialog()} {showArchived && (
{i18n('archiveHelperText')} diff --git a/ts/components/RelinkDialog.stories.tsx b/ts/components/RelinkDialog.stories.tsx index 45a91c628..93fa74cbb 100644 --- a/ts/components/RelinkDialog.stories.tsx +++ b/ts/components/RelinkDialog.stories.tsx @@ -13,7 +13,6 @@ import { action } from '@storybook/addon-actions'; const i18n = setupI18n('en', enMessages); const defaultProps = { - hasNetworkDialog: false, i18n, isRegistrationDone: true, relinkDevice: action('relink-device'), @@ -21,31 +20,19 @@ const defaultProps = { const permutations = [ { - title: 'Unlinked (online)', + title: 'Unlinked', props: { isRegistrationDone: false, }, }, - { - title: 'Unlinked (offline)', - props: { - hasNetworkDialog: true, - isRegistrationDone: false, - }, - }, ]; storiesOf('Components/RelinkDialog', module) .add('Knobs Playground', () => { - const hasNetworkDialog = boolean('hasNetworkDialog', false); const isRegistrationDone = boolean('isRegistrationDone', false); return ( - + ); }) .add('Iterations', () => { diff --git a/ts/components/RelinkDialog.tsx b/ts/components/RelinkDialog.tsx index 2b5860a3f..b9778d3fe 100644 --- a/ts/components/RelinkDialog.tsx +++ b/ts/components/RelinkDialog.tsx @@ -3,19 +3,17 @@ import React from 'react'; import { LocalizerType } from '../types/Util'; export interface PropsType { - hasNetworkDialog: boolean; i18n: LocalizerType; isRegistrationDone: boolean; relinkDevice: () => void; } export const RelinkDialog = ({ - hasNetworkDialog, i18n, isRegistrationDone, relinkDevice, }: PropsType): JSX.Element | null => { - if (hasNetworkDialog || isRegistrationDone) { + if (isRegistrationDone) { return null; } diff --git a/ts/state/selectors/network.ts b/ts/state/selectors/network.ts index 22dc26fc0..5d6939846 100644 --- a/ts/state/selectors/network.ts +++ b/ts/state/selectors/network.ts @@ -13,9 +13,9 @@ export const hasNetworkDialog = createSelector( { isOnline, socketStatus, withinConnectingGracePeriod }: NetworkStateType, isRegistrationDone: boolean ): boolean => - !isOnline || - !isRegistrationDone || - (socketStatus === WebSocket.CONNECTING && !withinConnectingGracePeriod) || - socketStatus === WebSocket.CLOSED || - socketStatus === WebSocket.CLOSING + isRegistrationDone && + (!isOnline || + (socketStatus === WebSocket.CONNECTING && !withinConnectingGracePeriod) || + socketStatus === WebSocket.CLOSED || + socketStatus === WebSocket.CLOSING) ); diff --git a/ts/state/smart/RelinkDialog.tsx b/ts/state/smart/RelinkDialog.tsx index 19d396668..ab89641a6 100644 --- a/ts/state/smart/RelinkDialog.tsx +++ b/ts/state/smart/RelinkDialog.tsx @@ -3,12 +3,10 @@ import { mapDispatchToProps } from '../actions'; import { RelinkDialog } from '../../components/RelinkDialog'; import { StateType } from '../reducer'; import { getIntl } from '../selectors/user'; -import { hasNetworkDialog } from '../selectors/network'; import { isDone } from '../../util/registration'; const mapStateToProps = (state: StateType) => { return { - hasNetworkDialog: hasNetworkDialog(state), i18n: getIntl(state), isRegistrationDone: isDone(), };