diff --git a/src/domain/session/settings/KeyBackupViewModel.js b/src/domain/session/settings/KeyBackupViewModel.js index 69e87e5d..b44de7e5 100644 --- a/src/domain/session/settings/KeyBackupViewModel.js +++ b/src/domain/session/settings/KeyBackupViewModel.js @@ -53,12 +53,11 @@ export class KeyBackupViewModel extends ViewModel { const keyBackup = this._session.keyBackup.get(); if (keyBackup) { status = keyBackup.needsNewKey ? Status.NewVersionAvailable : Status.Enabled; - } else { + } else if (keyBackup === null) { status = this.showPhraseSetup() ? Status.SetupPhrase : Status.SetupKey; - } /* TODO: bring back "waiting to get online" - else { + } else { status = Status.Pending; - } */ + } const changed = status !== this._status; this._status = status; return changed; diff --git a/src/matrix/Session.js b/src/matrix/Session.js index 17c809bd..868a743b 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -289,9 +289,15 @@ export class Session { } catch (err) { log.catch(err); } + return false; }); } + /** + * @type {ObservableValue<KeyBackup | undefined | null} + * - `undefined` means, we're not done with catchup sync yet and haven't checked yet if key backup is configured + * - `null` means we've checked and key backup hasn't been configured correctly or at all. + */ get keyBackup() { return this._keyBackup; } @@ -468,7 +474,7 @@ export class Session { log.set("success", true); await this._writeSSSSKey(ssssKey); } - }) + }); } const txn = await this._storage.readTxn([ this._storage.storeNames.session, @@ -478,8 +484,14 @@ export class Session { const ssssKey = await ssssReadKey(txn); if (ssssKey) { // txn will end here as this does a network request - await this._createKeyBackup(ssssKey, txn, log); - this._keyBackup.get()?.flush(log); + if (await this._createKeyBackup(ssssKey, txn, log)) { + this._keyBackup.get()?.flush(log); + } + } + if (!this._keyBackup.get()) { + // null means key backup isn't configured yet + // as opposed to undefined, which means we're still checking + this._keyBackup.set(null); } } // restore unfinished operations, like sending out room keys