diff --git a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx index 1022bf5ff2..517a56d23b 100644 --- a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx +++ b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx @@ -38,7 +38,7 @@ interface IState { eventCount: number; crawlingRoomsCount: number; roomCount: number; - currentRoom: string; + currentRoom: string | null; crawlerSleepTime: number; } @@ -61,7 +61,8 @@ export default class ManageEventIndexDialog extends React.Component => { const eventIndex = EventIndexPeg.get(); - let stats: IIndexStats; + if (!eventIndex) return; + let stats: IIndexStats | undefined; try { stats = await eventIndex.getStats(); @@ -71,7 +72,7 @@ export default class ManageEventIndexDialog extends React.Component => { const DisableEventIndexDialog = (await import("./DisableEventIndexDialog")).default; - Modal.createDialog(DisableEventIndexDialog, null, null, /* priority = */ false, /* static = */ true); + Modal.createDialog(DisableEventIndexDialog, undefined, undefined, /* priority = */ false, /* static = */ true); }; private onCrawlerSleepTimeChange = (e: ChangeEvent): void => { diff --git a/src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx b/src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx index 1669dd3c14..ec8cf31f30 100644 --- a/src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx @@ -49,7 +49,7 @@ interface IProps { } interface IState { - secureSecretStorage: boolean; + secureSecretStorage: boolean | null; phase: Phase; passPhrase: string; passPhraseValid: boolean; @@ -121,7 +121,7 @@ export default class CreateKeyBackupDialog extends React.PureComponent { this.setState({ - passPhraseValid: result.valid, + passPhraseValid: !!result.valid, }); }; @@ -306,7 +306,7 @@ export default class CreateKeyBackupDialog extends React.PureComponent diff --git a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx index 36ebf3ad8a..3e48739826 100644 --- a/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx +++ b/src/async-components/views/dialogs/security/CreateSecretStorageDialog.tsx @@ -81,13 +81,13 @@ interface IState { copied: boolean; downloaded: boolean; setPassphrase: boolean; - backupInfo: IKeyBackupInfo; - backupSigStatus: TrustInfo; + backupInfo: IKeyBackupInfo | null; + backupSigStatus: TrustInfo | null; // does the server offer a UI auth flow with just m.login.password // for /keys/device_signing/upload? - canUploadKeysWithPasswordOnly: boolean; + canUploadKeysWithPasswordOnly: boolean | null; accountPassword: string; - accountPasswordCorrect: boolean; + accountPasswordCorrect: boolean | null; canSkip: boolean; passPhraseKeySelected: string; error?: string; @@ -119,7 +119,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent { + private async fetchBackupInfo(): Promise<{ backupInfo?: IKeyBackupInfo; backupSigStatus?: TrustInfo }> { try { const backupInfo = await MatrixClientPeg.get().getKeyBackupVersion(); const backupSigStatus = // we may not have started crypto yet, in which case we definitely don't trust the backup - MatrixClientPeg.get().isCryptoEnabled() && (await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo)); + backupInfo && MatrixClientPeg.get().isCryptoEnabled() + ? await MatrixClientPeg.get().isKeyBackupTrusted(backupInfo) + : null; const { forceReset } = this.props; const phase = backupInfo && !forceReset ? Phase.Migrate : Phase.ChooseKeyPassphrase; @@ -189,17 +191,18 @@ export default class CreateSecretStorageDialog extends React.PureComponent { try { - await MatrixClientPeg.get().uploadDeviceSigningKeys(null, {} as CrossSigningKeys); + await MatrixClientPeg.get().uploadDeviceSigningKeys(undefined, {} as CrossSigningKeys); // We should never get here: the server should always require // UI auth to upload device signing keys. If we do, we upload // no keys which would be a no-op. @@ -248,7 +251,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent { e.preventDefault(); - if (this.state.backupSigStatus.usable) { + if (this.state.backupSigStatus?.usable) { this.bootstrapSecretStorage(); } else { this.restoreBackup(); @@ -265,7 +268,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent { - const blob = new Blob([this.recoveryKey.encodedPrivateKey], { + const blob = new Blob([this.recoveryKey.encodedPrivateKey!], { type: "text/plain;charset=us-ascii", }); FileSaver.saveAs(blob, "security-key.txt"); @@ -323,7 +326,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent => { this.setState({ phase: Phase.Storing, - error: null, + error: undefined, }); const cli = MatrixClientPeg.get(); @@ -351,7 +354,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent this.recoveryKey, - keyBackupInfo: this.state.backupInfo, + keyBackupInfo: this.state.backupInfo!, setupNewKeyBackup: !this.state.backupInfo, getKeyBackupPassphrase: async (): Promise => { // We may already have the backup key if we earlier went @@ -399,14 +402,14 @@ export default class CreateSecretStorageDialog extends React.PureComponent { this.setState({ - passPhraseValid: result.valid, + passPhraseValid: !!result.valid, }); }; @@ -581,13 +584,13 @@ export default class CreateSecretStorageDialog extends React.PureComponent ); - } else if (!this.state.backupSigStatus.usable) { + } else if (!this.state.backupSigStatus?.usable) { authPrompt = (
{_t("Restore your key backup to upgrade your encryption")}
@@ -612,7 +615,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent