diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-09-02 17:27:34 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-09-05 12:05:03 +0200 |
| commit | 8fbb38534cd6621c0e3e1f0a5ae9daf7027275ff (patch) | |
| tree | 9bc94e798578ff3678c448526ea051e269c08870 /gui/src | |
| parent | 61fb4e1bc8ce9c9d73296d52fd2cdad0b10376aa (diff) | |
| download | mullvadvpn-8fbb38534cd6621c0e3e1f0a5ae9daf7027275ff.tar.xz mullvadvpn-8fbb38534cd6621c0e3e1f0a5ae9daf7027275ff.zip | |
Fix logout dialog flickering
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/Account.tsx | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gui/src/renderer/components/Account.tsx b/gui/src/renderer/components/Account.tsx index eabde95dbb..2ab21f7d30 100644 --- a/gui/src/renderer/components/Account.tsx +++ b/gui/src/renderer/components/Account.tsx @@ -42,11 +42,14 @@ interface IProps { } interface IState { - logoutDialogState: 'hidden' | 'checking-ports' | 'confirm'; + logoutDialogVisible: boolean; + logoutDialogStage?: 'checking-ports' | 'confirm'; } export default class Account extends React.Component<IProps, IState> { - public state: IState = { logoutDialogState: 'hidden' }; + public state: IState = { + logoutDialogVisible: false, + }; public componentDidMount() { this.props.updateAccountData(); @@ -140,10 +143,10 @@ export default class Account extends React.Component<IProps, IState> { private renderLogoutDialog() { const modalType = - this.state.logoutDialogState === 'checking-ports' ? undefined : ModalAlertType.warning; + this.state.logoutDialogStage === 'checking-ports' ? undefined : ModalAlertType.warning; const message = - this.state.logoutDialogState === 'checking-ports' ? ( + this.state.logoutDialogStage === 'checking-ports' ? ( <StyledSpinnerContainer> <ImageView source="icon-spinner" width={60} height={60} /> </StyledSpinnerContainer> @@ -160,7 +163,7 @@ export default class Account extends React.Component<IProps, IState> { ); const buttons = - this.state.logoutDialogState === 'checking-ports' + this.state.logoutDialogStage === 'checking-ports' ? [] : [ <AppButton.RedButton key="logout" onClick={this.props.onLogout}> @@ -175,17 +178,14 @@ export default class Account extends React.Component<IProps, IState> { ]; return ( - <ModalAlert - isOpen={this.state.logoutDialogState !== 'hidden'} - type={modalType} - buttons={buttons}> + <ModalAlert isOpen={this.state.logoutDialogVisible} type={modalType} buttons={buttons}> {message} </ModalAlert> ); } private onTryLogout = async () => { - this.setState({ logoutDialogState: 'checking-ports' }); + this.setState({ logoutDialogVisible: true, logoutDialogStage: 'checking-ports' }); this.props.prepareLogout(); const deviceState = await this.props.getDeviceState(); @@ -194,7 +194,7 @@ export default class Account extends React.Component<IProps, IState> { deviceState.accountAndDevice.device?.ports !== undefined && deviceState.accountAndDevice.device.ports.length > 0 ) { - this.setState({ logoutDialogState: 'confirm' }); + this.setState({ logoutDialogStage: 'confirm' }); } else { this.props.onLogout(); this.onHideLogoutConfirmationDialog(); @@ -207,7 +207,7 @@ export default class Account extends React.Component<IProps, IState> { }; private onHideLogoutConfirmationDialog = () => { - this.setState({ logoutDialogState: 'hidden' }); + this.setState({ logoutDialogVisible: false }); }; } |
