Skip to content

Commit

Permalink
Fix backup button in logout dialog
Browse files Browse the repository at this point in the history
We set the caption appropriately but forgot to actually do the
right thing depending on whether there was a key backup already.

Also fix the loadihng spinner which was never shown.

Fixes element-hq/element-web#8369
  • Loading branch information
dbkr committed Feb 27, 2019
1 parent 68ba149 commit 98402e7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/views/dialogs/LogoutDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ export default class LogoutDialog extends React.Component {
this._onSetRecoveryMethodClick = this._onSetRecoveryMethodClick.bind(this);
this._onLogoutConfirm = this._onLogoutConfirm.bind(this);

const shouldLoadBackupStatus = !MatrixClientPeg.get().getKeyBackupEnabled();

this.state = {
loading: false,
loading: shouldLoadBackupStatus,
backupInfo: null,
error: null,
};

if (!MatrixClientPeg.get().getKeyBackupEnabled()) {
if (shouldLoadBackupStatus) {
this._loadBackupStatus();
}
}
Expand Down Expand Up @@ -84,9 +86,17 @@ export default class LogoutDialog extends React.Component {
}

_onSetRecoveryMethodClick() {
Modal.createTrackedDialogAsync('Key Backup', 'Key Backup',
import('../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog'),
);
if (this.state.backupInfo) {
// A key backup exists for this account, but the creating device is not
// verified, so restore the backup which will give us the keys from it and
// allow us to trust it (ie. upload keys to it)
const RestoreKeyBackupDialog = sdk.getComponent('dialogs.keybackup.RestoreKeyBackupDialog');
Modal.createTrackedDialog('Restore Backup', '', RestoreKeyBackupDialog, {});
} else {
Modal.createTrackedDialogAsync("Key Backup", "Key Backup",
import("../../../async-components/views/dialogs/keybackup/CreateKeyBackupDialog"),
);
}

// close dialog
this.props.onFinished();
Expand Down

0 comments on commit 98402e7

Please sign in to comment.