Move state update listeners from constructor to componentDidMount (#28341)
* Move state update listeners from constructor to componentDidMount Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2d9982f9f0
commit
0899165d9e
@@ -64,6 +64,11 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
|
||||
|
||||
this.unmounted = false;
|
||||
this.issueRef = React.createRef();
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.unmounted = false;
|
||||
this.issueRef.current?.focus();
|
||||
|
||||
// Get all of the extra info dumped to the console when someone is about
|
||||
// to send debug logs. Since this is a fire and forget action, we do
|
||||
@@ -76,10 +81,6 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
|
||||
});
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.issueRef.current?.focus();
|
||||
}
|
||||
|
||||
public componentWillUnmount(): void {
|
||||
this.unmounted = true;
|
||||
}
|
||||
|
||||
@@ -113,14 +113,6 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
||||
nameIsValid: false,
|
||||
canChangeEncryption: false,
|
||||
};
|
||||
|
||||
checkUserIsAllowedToChangeEncryption(cli, Preset.PrivateChat).then(({ allowChange, forcedValue }) =>
|
||||
this.setState((state) => ({
|
||||
canChangeEncryption: allowChange,
|
||||
// override with forcedValue if it is set
|
||||
isEncrypted: forcedValue ?? state.isEncrypted,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
private roomCreateOptions(): IOpts {
|
||||
@@ -160,6 +152,15 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
const cli = MatrixClientPeg.safeGet();
|
||||
checkUserIsAllowedToChangeEncryption(cli, Preset.PrivateChat).then(({ allowChange, forcedValue }) =>
|
||||
this.setState((state) => ({
|
||||
canChangeEncryption: allowChange,
|
||||
// override with forcedValue if it is set
|
||||
isEncrypted: forcedValue ?? state.isEncrypted,
|
||||
})),
|
||||
);
|
||||
|
||||
// move focus to first field when showing dialog
|
||||
this.nameField.current?.focus();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
|
||||
authData: null, // for UIA
|
||||
authEnabled: true, // see usages for information
|
||||
};
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.initAuth(/* shouldErase= */ false);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ export default class IncomingSasDialog extends React.Component<IProps, IState> {
|
||||
opponentProfileError: null,
|
||||
sas: null,
|
||||
};
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.props.verifier.on(VerifierEvent.ShowSas, this.onVerifierShowSas);
|
||||
this.props.verifier.on(VerifierEvent.Cancel, this.onVerifierCancel);
|
||||
this.fetchOpponentProfile();
|
||||
|
||||
@@ -397,6 +397,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.unmounted = false;
|
||||
this.encryptionByDefault = privateShouldBeEncrypted(MatrixClientPeg.safeGet());
|
||||
|
||||
if (this.props.initialText) {
|
||||
|
||||
@@ -81,9 +81,10 @@ export default class LogoutDialog extends React.Component<IProps, IState> {
|
||||
this.state = {
|
||||
backupStatus: BackupStatus.LOADING,
|
||||
};
|
||||
}
|
||||
|
||||
// we can't call setState() immediately, so wait a beat
|
||||
window.setTimeout(() => this.startLoadBackupStatus(), 0);
|
||||
public componentDidMount(): void {
|
||||
this.startLoadBackupStatus();
|
||||
}
|
||||
|
||||
/** kick off the asynchronous calls to populate `state.backupStatus` in the background */
|
||||
|
||||
@@ -32,6 +32,9 @@ export default class VerificationRequestDialog extends React.Component<IProps, I
|
||||
this.state = {
|
||||
verificationRequest: this.props.verificationRequest,
|
||||
};
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.props.verificationRequestPromise?.then((r) => {
|
||||
this.setState({ verificationRequest: r });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user