Conform more code to strict null checking (#10169)

* Conform more code to strict null checking

* delint

* Iterate

* delint

* Fix bad test
This commit is contained in:
Michael Telatynski 2023-02-16 09:38:44 +00:00 committed by GitHub
parent 5123d7e641
commit e8b92b308b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 283 additions and 287 deletions

View file

@ -41,7 +41,7 @@ const KEY_FILE_MAX_SIZE = 128;
const VALIDATION_THROTTLE_MS = 200;
interface IProps extends IDialogProps {
keyInfo: ISecretStorageKeyInfo;
keyInfo?: ISecretStorageKeyInfo;
checkPrivateKey: (k: { passphrase?: string; recoveryKey?: string }) => boolean;
}
@ -137,7 +137,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
};
private onRecoveryKeyFileChange = async (ev: ChangeEvent<HTMLInputElement>): Promise<void> => {
if (ev.target.files.length === 0) return;
if (!ev.target.files?.length) return;
const f = ev.target.files[0];
@ -170,7 +170,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
};
private onRecoveryKeyFileUploadClick = (): void => {
this.fileUpload.current.click();
this.fileUpload.current?.click();
};
private onPassPhraseNext = async (ev: FormEvent<HTMLFormElement> | React.MouseEvent): Promise<void> => {
@ -269,15 +269,11 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
}
public render(): React.ReactNode {
const hasPassphrase =
this.props.keyInfo &&
this.props.keyInfo.passphrase &&
this.props.keyInfo.passphrase.salt &&
this.props.keyInfo.passphrase.iterations;
const hasPassphrase = this.props.keyInfo?.passphrase?.salt && this.props.keyInfo?.passphrase?.iterations;
const resetButton = (
<div className="mx_AccessSecretStorageDialog_reset">
{_t("Forgotten or lost all recovery methods? <a>Reset all</a>", null, {
{_t("Forgotten or lost all recovery methods? <a>Reset all</a>", undefined, {
a: (sub) => (
<AccessibleButton
kind="link_inline"
@ -405,7 +401,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
value={this.state.recoveryKey}
onChange={this.onRecoveryKeyChange}
autoFocus={true}
forceValidity={this.state.recoveryKeyCorrect}
forceValidity={this.state.recoveryKeyCorrect ?? undefined}
autoComplete="off"
/>
</div>