Delay encryption setup toasts until encrypted rooms present

Part of https://github.com/vector-im/element-web/issues/13895
This commit is contained in:
J. Ryan Stinnett 2020-09-16 12:25:02 +01:00
parent 0d25f62a9a
commit 6130d9e882

View file

@ -29,7 +29,6 @@ import {
hideToast as hideUnverifiedSessionsToast, hideToast as hideUnverifiedSessionsToast,
showToast as showUnverifiedSessionsToast, showToast as showUnverifiedSessionsToast,
} from "./toasts/UnverifiedSessionToast"; } from "./toasts/UnverifiedSessionToast";
import { privateShouldBeEncrypted } from "./createRoom";
import { isSecretStorageBeingAccessed, accessSecretStorage } from "./SecurityManager"; import { isSecretStorageBeingAccessed, accessSecretStorage } from "./SecurityManager";
import { isSecureBackupRequired } from './utils/WellKnownUtils'; import { isSecureBackupRequired } from './utils/WellKnownUtils';
import { isLoggedIn } from './components/structures/MatrixChat'; import { isLoggedIn } from './components/structures/MatrixChat';
@ -201,9 +200,7 @@ export default class DeviceListener {
// If we're in the middle of a secret storage operation, we're likely // 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. // modifying the state involved here, so don't add new toasts to setup.
if (isSecretStorageBeingAccessed()) return false; if (isSecretStorageBeingAccessed()) return false;
// In a default configuration, show the toasts. If the well-known config causes e2ee default to be false // Show setup toasts once the user is in at least one encrypted room.
// then do not show the toasts until user is in at least one encrypted room.
if (privateShouldBeEncrypted()) return true;
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
return cli && cli.getRooms().some(r => cli.isRoomEncrypted(r.roomId)); return cli && cli.getRooms().some(r => cli.isRoomEncrypted(r.roomId));
} }
@ -219,8 +216,6 @@ export default class DeviceListener {
// (we add a listener on sync to do once check after the initial sync is done) // (we add a listener on sync to do once check after the initial sync is done)
if (!cli.isInitialSyncComplete()) return; if (!cli.isInitialSyncComplete()) return;
// JRS: This will change again in the next PR which moves secret storage
// later in the process.
const crossSigningReady = await cli.isCrossSigningReady(); const crossSigningReady = await cli.isCrossSigningReady();
const secretStorageReady = await cli.isSecretStorageReady(); const secretStorageReady = await cli.isSecretStorageReady();
const allSystemsReady = crossSigningReady && secretStorageReady; const allSystemsReady = crossSigningReady && secretStorageReady;