diff --git a/src/domain/session/settings/SessionBackupViewModel.js b/src/domain/session/settings/SessionBackupViewModel.js index 2fee7b82..d924fae6 100644 --- a/src/domain/session/settings/SessionBackupViewModel.js +++ b/src/domain/session/settings/SessionBackupViewModel.js @@ -23,6 +23,9 @@ export class SessionBackupViewModel extends ViewModel { this._showKeySetup = true; this._error = null; this._isBusy = false; + this.track(this._session.hasSecretStorageKey.subscribe(() => { + this.emitChange("status"); + })); } get isBusy() { @@ -37,7 +40,11 @@ export class SessionBackupViewModel extends ViewModel { if (this._session.sessionBackup) { return "enabled"; } else { - return this._showKeySetup ? "setupKey" : "setupPhrase"; + if (this._session.hasSecretStorageKey.get() === false) { + return this._showKeySetup ? "setupKey" : "setupPhrase"; + } else { + return "pending"; + } } } diff --git a/src/matrix/Session.js b/src/matrix/Session.js index d2d65cf9..f83dda95 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -63,6 +63,7 @@ export class Session { this._olmWorker = olmWorker; this._cryptoDriver = cryptoDriver; this._sessionBackup = null; + this._hasSecretStorageKey = new ObservableValue(null); if (olm) { this._olmUtil = new olm.Utility(); @@ -82,6 +83,10 @@ export class Session { return this._e2eeAccount?.identityKeys.ed25519; } + get hasSecretStorageKey() { + return this._hasSecretStorageKey; + } + get deviceId() { return this._sessionInfo.deviceId; } @@ -175,6 +180,9 @@ export class Session { if (!this._olm) { throw new Error("olm required"); } + if (this._sessionBackup) { + return false; + } const key = await ssssKeyFromCredential(type, credential, this._storage, this._cryptoDriver, this._olm); // and create session backup, which needs to read from accountData const readTxn = this._storage.readTxn([ @@ -193,6 +201,7 @@ export class Session { throw err; } await writeTxn.complete(); + this._hasSecretStorageKey.set(true); } async _createSessionBackup(ssssKey, txn) { @@ -297,6 +306,7 @@ export class Session { // txn will end here as this does a network request await this._createSessionBackup(ssssKey, txn); } + this._hasSecretStorageKey.set(!!ssssKey); } // restore unfinished operations, like sending out room keys const opsTxn = this._storage.readWriteTxn([ diff --git a/src/ui/web/session/settings/SessionBackupSettingsView.js b/src/ui/web/session/settings/SessionBackupSettingsView.js index 162f2525..c1c0e455 100644 --- a/src/ui/web/session/settings/SessionBackupSettingsView.js +++ b/src/ui/web/session/settings/SessionBackupSettingsView.js @@ -15,6 +15,7 @@ limitations under the License. */ import {TemplateView} from "../../general/TemplateView.js"; +import {StaticView} from "../../general/StaticView.js"; export class SessionBackupSettingsView extends TemplateView { render(t, vm) { @@ -23,6 +24,7 @@ export class SessionBackupSettingsView extends TemplateView { case "enabled": return new TemplateView(vm, renderEnabled) case "setupKey": return new TemplateView(vm, renderEnableFromKey) case "setupPhrase": return new TemplateView(vm, renderEnableFromPhrase) + case "pending": return new StaticView(vm, t => t.p(vm.i18n`Waiting to go onlineā€¦`)) } }); }