diff --git a/src/components/views/settings/encryption/ChangeRecoveryKey.tsx b/src/components/views/settings/encryption/ChangeRecoveryKey.tsx index 7bbd998183e..aec2aef078c 100644 --- a/src/components/views/settings/encryption/ChangeRecoveryKey.tsx +++ b/src/components/views/settings/encryption/ChangeRecoveryKey.tsx @@ -65,13 +65,7 @@ export function ChangeRecoveryKey({ const [state, setState] = useState(isSetupFlow ? "inform_user" : "save_key_change_flow"); // We create a new recovery key, the recovery key will be displayed to the user - const recoveryKey = useAsyncMemo(() => { - const crypto = matrixClient.getCrypto(); - if (!crypto) return Promise.resolve(undefined); - - return crypto.createRecoveryKeyFromPassphrase(); - }, []); - + const recoveryKey = useAsyncMemo(() => matrixClient.getCrypto()!.createRecoveryKeyFromPassphrase(), []); if (!recoveryKey?.encodedPrivateKey) return null; let content: JSX.Element; diff --git a/src/components/views/settings/encryption/RecoveryPanel.tsx b/src/components/views/settings/encryption/RecoveryPanel.tsx index df555a583ad..960a0c26374 100644 --- a/src/components/views/settings/encryption/RecoveryPanel.tsx +++ b/src/components/views/settings/encryption/RecoveryPanel.tsx @@ -46,8 +46,7 @@ export function RecoveryPanel({ onSetUpRecoveryClick, onChangingRecoveryKeyClick const matrixClient = useMatrixClientContext(); const checkEncryption = useCallback(async () => { - const crypto = matrixClient.getCrypto(); - if (!crypto) return; + const crypto = matrixClient.getCrypto()!; // Check if the user has a backup const hasBackup = Boolean(await crypto.checkKeyBackupAndEnable()); diff --git a/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx b/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx index 97e6ed1ab53..3908646dae5 100644 --- a/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx @@ -78,9 +78,7 @@ function useVerificationRequired(setState: (state: State) => void): () => Promis const matrixClient = useMatrixClientContext(); const checkVerificationRequired = useCallback(async () => { - const crypto = matrixClient.getCrypto(); - if (!crypto) return; - + const crypto = matrixClient.getCrypto()!; const isCrossSigningReady = await crypto.isCrossSigningReady(); if (isCrossSigningReady) setState("main"); else setState("verification_required");