Add some catches

pull/21833/head
Travis Ralston 2021-04-08 18:09:41 -06:00
parent 01c5f84f60
commit f2e2f1699b
1 changed files with 36 additions and 26 deletions

View File

@ -222,34 +222,44 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
// rest of this function. // rest of this function.
Modal.toggleCurrentDialogVisibility(); Modal.toggleCurrentDialogVisibility();
// Force reset secret storage (which resets the key backup) try {
await accessSecretStorage(async () => { // Force reset secret storage (which resets the key backup)
// Now reset cross-signing so everything Just Works™ again. await accessSecretStorage(async () => {
const cli = MatrixClientPeg.get(); try {
await cli.bootstrapCrossSigning({ // Now reset cross-signing so everything Just Works™ again.
authUploadDeviceSigningKeys: async (makeRequest) => { const cli = MatrixClientPeg.get();
// XXX: Making this an import breaks the app. await cli.bootstrapCrossSigning({
const InteractiveAuthDialog = sdk.getComponent("views.dialogs.InteractiveAuthDialog"); authUploadDeviceSigningKeys: async (makeRequest) => {
const { finished } = Modal.createTrackedDialog( // XXX: Making this an import breaks the app.
'Cross-signing keys dialog', '', InteractiveAuthDialog, const InteractiveAuthDialog = sdk.getComponent("views.dialogs.InteractiveAuthDialog");
{ const {finished} = Modal.createTrackedDialog(
title: _t("Setting up keys"), 'Cross-signing keys dialog', '', InteractiveAuthDialog,
matrixClient: cli, {
makeRequest, title: _t("Setting up keys"),
matrixClient: cli,
makeRequest,
},
);
const [confirmed] = await finished;
if (!confirmed) {
throw new Error("Cross-signing key upload auth canceled");
}
}, },
); setupNewCrossSigning: true,
const [confirmed] = await finished; });
if (!confirmed) {
throw new Error("Cross-signing key upload auth canceled");
}
},
setupNewCrossSigning: true,
});
// Now we can indicate that the user is done pressing buttons, finally. // Now we can indicate that the user is done pressing buttons, finally.
// Upstream flows will detect the new secret storage, key backup, etc and use it. // Upstream flows will detect the new secret storage, key backup, etc and use it.
this.props.onFinished(true); this.props.onFinished(true);
}, true); } catch (e) {
console.error(e);
this.props.onFinished(false);
}
}, true);
} catch (e) {
console.error(e);
this.props.onFinished(false);
}
}; };
private getKeyValidationText(): string { private getKeyValidationText(): string {