Catch errors after syncing recovery (#29691)
* Allow setting the Encryption settings tab to any initial state * Add a variant to the reset flow for 'sync_failed' * Catch errors after syncing recovery Fixes #29229 * fixup! Allow setting the Encryption settings tab to any initial state * fixup! Add a variant to the reset flow for 'sync_failed' * Move docs for identity panel variants to ResetIdentityPanelVariant
This commit is contained in:
@@ -14,7 +14,7 @@ import Modal from "../Modal";
|
||||
import { _t } from "../languageHandler";
|
||||
import DeviceListener from "../DeviceListener";
|
||||
import SetupEncryptionDialog from "../components/views/dialogs/security/SetupEncryptionDialog";
|
||||
import { accessSecretStorage } from "../SecurityManager";
|
||||
import { AccessCancelledError, accessSecretStorage } from "../SecurityManager";
|
||||
import ToastStore from "../stores/ToastStore";
|
||||
import GenericToast from "../components/views/toasts/GenericToast";
|
||||
import { ModuleRunner } from "../modules/ModuleRunner";
|
||||
@@ -153,6 +153,8 @@ export const showToast = (kind: Kind): void => {
|
||||
);
|
||||
try {
|
||||
await accessSecretStorage();
|
||||
} catch (error) {
|
||||
onAccessSecretStorageFailed(error as Error);
|
||||
} finally {
|
||||
modal.close();
|
||||
}
|
||||
@@ -165,7 +167,7 @@ export const showToast = (kind: Kind): void => {
|
||||
const payload: OpenToTabPayload = {
|
||||
action: Action.ViewUserSettings,
|
||||
initialTabId: UserTab.Encryption,
|
||||
props: { showResetIdentity: true },
|
||||
props: { initialEncryptionState: "reset_identity_forgot" },
|
||||
};
|
||||
defaultDispatcher.dispatch(payload);
|
||||
} else {
|
||||
@@ -173,6 +175,27 @@ export const showToast = (kind: Kind): void => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* We tried to accessSecretStorage, which triggered us to ask for the
|
||||
* recovery key, but this failed. If the user just gave up, that is fine,
|
||||
* but if not, that means downloading encryption info from 4S did not fix
|
||||
* the problem we identified. Presumably, something is wrong with what
|
||||
* they have in 4S: we tell them to reset their identity.
|
||||
*/
|
||||
const onAccessSecretStorageFailed = (error: Error): void => {
|
||||
if (error instanceof AccessCancelledError) {
|
||||
// The user cancelled the dialog - just allow it to close
|
||||
} else {
|
||||
// A real error happened - jump to the reset identity tab
|
||||
const payload: OpenToTabPayload = {
|
||||
action: Action.ViewUserSettings,
|
||||
initialTabId: UserTab.Encryption,
|
||||
props: { initialEncryptionState: "reset_identity_sync_failed" },
|
||||
};
|
||||
defaultDispatcher.dispatch(payload);
|
||||
}
|
||||
};
|
||||
|
||||
ToastStore.sharedInstance().addOrReplaceToast({
|
||||
key: TOAST_KEY,
|
||||
title: getTitle(kind),
|
||||
|
||||
Reference in New Issue
Block a user