Avoid adding setup toast in the middle of setup
This improves the experience of going through secret storage setup / reset flows by avoiding intermittent toasts that appear and disappear in the middle of the operation.
This commit is contained in:
parent
fed7ebb6bc
commit
e8e691b746
2 changed files with 16 additions and 1 deletions
|
@ -35,6 +35,17 @@ function isCachingAllowed() {
|
||||||
return secretStorageBeingAccessed;
|
return secretStorageBeingAccessed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can be used by other components to check if secret storage access is in
|
||||||
|
* progress, so that we can e.g. avoid intermittently showing toasts during
|
||||||
|
* secret storage setup.
|
||||||
|
*
|
||||||
|
* @returns {bool}
|
||||||
|
*/
|
||||||
|
export function isSecretStorageBeingAccessed() {
|
||||||
|
return secretStorageBeingAccessed;
|
||||||
|
}
|
||||||
|
|
||||||
export class AccessCancelledError extends Error {
|
export class AccessCancelledError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Secret storage access canceled");
|
super("Secret storage access canceled");
|
||||||
|
|
|
@ -28,7 +28,8 @@ import {
|
||||||
hideToast as hideUnverifiedSessionsToast,
|
hideToast as hideUnverifiedSessionsToast,
|
||||||
showToast as showUnverifiedSessionsToast,
|
showToast as showUnverifiedSessionsToast,
|
||||||
} from "./toasts/UnverifiedSessionToast";
|
} from "./toasts/UnverifiedSessionToast";
|
||||||
import {privateShouldBeEncrypted} from "./createRoom";
|
import { privateShouldBeEncrypted } from "./createRoom";
|
||||||
|
import { isSecretStorageBeingAccessed } from "./CrossSigningManager";
|
||||||
|
|
||||||
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
|
const KEY_BACKUP_POLL_INTERVAL = 5 * 60 * 1000;
|
||||||
|
|
||||||
|
@ -170,6 +171,9 @@ export default class DeviceListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowSetupEncryptionToast() {
|
private shouldShowSetupEncryptionToast() {
|
||||||
|
// 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;
|
||||||
// In a default configuration, show the toasts. If the well-known config causes e2ee default to be false
|
// In a default configuration, show the toasts. If the well-known config causes e2ee default to be false
|
||||||
// then do not show the toasts until 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;
|
if (privateShouldBeEncrypted()) return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue