Show 'Verify this device' toast even if there are no encrypted rooms yet (#32891)

* Show 'Verify this device' toast even if there are no encrypted rooms yet

* Close verify toast in more tests
This commit is contained in:
Andy Balaam
2026-04-24 11:39:59 +00:00
committed by GitHub
parent 6c7c90c15d
commit 76b65b14de
36 changed files with 219 additions and 144 deletions
@@ -24,7 +24,6 @@ import {
showToast as showSetupEncryptionToast,
} from "../toasts/SetupEncryptionToast";
import { isSecretStorageBeingAccessed } from "../SecurityManager";
import { asyncSomeParallel } from "../utils/arrays";
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
@@ -271,10 +270,12 @@ export class DeviceListenerCurrentDevice {
if (newState === "ok" || this.dismissedThisDeviceToast) {
hideSetupEncryptionToast();
} else if (await this.shouldShowSetupEncryptionToast()) {
} else if (!isSecretStorageBeingAccessed()) {
showSetupEncryptionToast(newState);
} else {
logSpan.info("Not yet ready, but shouldShowSetupEncryptionToast==false");
// If we're in the middle of a secret storage operation, we're likely
// modifying the state involved here, so don't add new toasts to setup.
logSpan.info("Device is not yet ready, but secret storage is being accessed, so not showing toast.");
}
}
@@ -386,23 +387,6 @@ export class DeviceListenerCurrentDevice {
return this.keyBackupInfo;
}
/**
* Is the user in at least one encrypted room?
*/
private async shouldShowSetupEncryptionToast(): Promise<boolean> {
// If we're in the middle of a secret storage operation, we're likely
// modifying the state involved here, so don't add new toasts to setup.
if (isSecretStorageBeingAccessed()) return false;
// Show setup toasts once the user is in at least one encrypted room.
const cryptoApi = this.client.getCrypto();
if (!cryptoApi) return false;
return await asyncSomeParallel(this.client.getRooms(), ({ roomId }) =>
cryptoApi.isEncryptionEnabledInRoom(roomId),
);
}
/**
* Is key backup enabled? Use a cached answer if we have one.
*/