Don't show the key storage out of sync toast when backup disabled (#31506)

This commit is contained in:
Hubert Chathi 2025-12-10 11:03:47 -05:00 committed by GitHub
parent cff9119324
commit 4bd8eeb17a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View File

@ -438,7 +438,10 @@ export default class DeviceListener {
// said we are OK with that.
const keyBackupIsOk = keyBackupUploadActive || backupDisabled;
const backupKeyCached = (await crypto.getSessionBackupPrivateKey()) !== null;
// If key backup is active and not disabled: do we have the backup key
// cached locally?
const backupKeyCached =
!keyBackupUploadActive || backupDisabled || (await crypto.getSessionBackupPrivateKey()) !== null;
const allSystemsReady =
isCurrentDeviceTrusted && allCrossSigningSecretsCached && keyBackupIsOk && recoveryIsOk && backupKeyCached;

View File

@ -367,7 +367,7 @@ describe("DeviceListener", () => {
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
});
it("shows an out-of-sync toast when one of the secrets is missing locally", async () => {
it("shows an out-of-sync toast when one of the cross-signing secrets is missing locally", async () => {
mockCrypto!.getCrossSigningStatus.mockResolvedValue({
publicKeysOnDevice: true,
privateKeysInSecretStorage: true,
@ -385,6 +385,30 @@ describe("DeviceListener", () => {
);
});
it("shows an out-of-sync toast when the backup key is missing locally", async () => {
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
mockCrypto!.getActiveSessionBackupVersion.mockResolvedValue("1");
mockCrypto!.getSessionBackupPrivateKey.mockResolvedValue(null);
await createAndStart();
expect(SetupEncryptionToast.showToast).toHaveBeenCalledWith(
SetupEncryptionToast.Kind.KEY_STORAGE_OUT_OF_SYNC,
);
});
it("does not show an out-of-sync toast when the backup key is missing locally but backup is purposely disabled", async () => {
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
mockCrypto!.getSessionBackupPrivateKey.mockResolvedValue(null);
mockClient.getAccountDataFromServer.mockImplementation((eventType) =>
eventType === BACKUP_DISABLED_ACCOUNT_DATA_KEY ? ({ disabled: true } as any) : null,
);
await createAndStart();
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
});
it("hides the out-of-sync toast after we receive the missing secrets", async () => {
mockCrypto!.getSecretStorageStatus.mockResolvedValue(readySecretStorageStatus);
mockCrypto!.getActiveSessionBackupVersion.mockResolvedValue("1");