mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 20:26:19 +02:00
Remodel DeviceListener ifs to be more uniform
We enter this chain of `if`s if at lease one of the boolean flags is false. This change attempts to make the logic clearer by ensuring that each branch of the if matches exactly one of those booleans. Justifying this change: if `secretStorageStatus.defaultKeyId === null` then `recoveryKeyIsOk` will be false, except in the strange case where recovery is disabled, in which case we should not be dealing with problems with recovery anyway, so if we previously entered this branch it would have been a bug. All existing tests pass so it looks like we didn't consider this case.
This commit is contained in:
parent
59d3de0998
commit
883bd3adb8
@ -214,28 +214,30 @@ export class DeviceListenerCurrentDevice {
|
||||
} else if (!keyBackupUploadIsOk) {
|
||||
logSpan.info("Key backup upload is unexpectedly turned off: setting state to TURN_ON_KEY_STORAGE");
|
||||
await this.setDeviceState("turn_on_key_storage", logSpan);
|
||||
} else if (secretStorageStatus.defaultKeyId === null) {
|
||||
// The user just hasn't set up 4S yet: if they have key
|
||||
// backup, prompt them to turn on recovery too. (If not, they
|
||||
// have explicitly opted out, so don't hassle them.)
|
||||
if (recoveryDisabled) {
|
||||
logSpan.info("Recovery disabled: no toast needed");
|
||||
await this.setDeviceState("ok", logSpan);
|
||||
} else if (keyBackupUploadActive) {
|
||||
logSpan.info("No default 4S key: setting state to SET_UP_RECOVERY");
|
||||
await this.setDeviceState("set_up_recovery", logSpan);
|
||||
} else {
|
||||
logSpan.info("No default 4S key but backup disabled: no toast needed");
|
||||
await this.setDeviceState("ok", logSpan);
|
||||
}
|
||||
} else if (!recoveryIsOk) {
|
||||
logSpan.warn("4S is missing secrets: setting state to KEY_STORAGE_OUT_OF_SYNC", {
|
||||
secretStorageStatus,
|
||||
allCrossSigningSecretsCached,
|
||||
isCurrentDeviceTrusted,
|
||||
keyBackupDownloadIsOk,
|
||||
});
|
||||
await this.setDeviceState("key_storage_out_of_sync", logSpan);
|
||||
if (secretStorageStatus.defaultKeyId === null) {
|
||||
// The user just hasn't set up 4S yet: if they have key
|
||||
// backup, prompt them to turn on recovery too. (If not, they
|
||||
// have explicitly opted out, so don't hassle them.)
|
||||
if (recoveryDisabled) {
|
||||
logSpan.info("Recovery disabled: no toast needed");
|
||||
await this.setDeviceState("ok", logSpan);
|
||||
} else if (keyBackupUploadActive) {
|
||||
logSpan.info("No default 4S key: setting state to SET_UP_RECOVERY");
|
||||
await this.setDeviceState("set_up_recovery", logSpan);
|
||||
} else {
|
||||
logSpan.info("No default 4S key but backup disabled: no toast needed");
|
||||
await this.setDeviceState("ok", logSpan);
|
||||
}
|
||||
} else {
|
||||
logSpan.warn("4S is missing secrets: setting state to KEY_STORAGE_OUT_OF_SYNC", {
|
||||
secretStorageStatus,
|
||||
allCrossSigningSecretsCached,
|
||||
isCurrentDeviceTrusted,
|
||||
keyBackupDownloadIsOk,
|
||||
});
|
||||
await this.setDeviceState("key_storage_out_of_sync", logSpan);
|
||||
}
|
||||
} else if (!keyBackupDownloadIsOk) {
|
||||
logSpan.warn("Backup key is not cached locally: setting state to KEY_STORAGE_OUT_OF_SYNC", {
|
||||
secretStorageStatus,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user