Conform more of the codebase to strictNullChecks
(#10358
* Conform more of the codebase to `strictNullChecks` * Fix types * Iterate * Iterate
This commit is contained in:
parent
41d88ad6ae
commit
503df62191
76 changed files with 323 additions and 327 deletions
|
@ -47,7 +47,7 @@ interface IProps {
|
|||
|
||||
interface IState {
|
||||
canRedact: boolean;
|
||||
sendStatus: EventStatus;
|
||||
sendStatus: EventStatus | null;
|
||||
}
|
||||
|
||||
export default class EditHistoryMessage extends React.PureComponent<IProps, IState> {
|
||||
|
@ -59,12 +59,10 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
|
|||
super(props);
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
const { userId } = cli.credentials;
|
||||
const userId = cli.getSafeUserId();
|
||||
const event = this.props.mxEvent;
|
||||
const room = cli.getRoom(event.getRoomId());
|
||||
if (event.localRedactionEvent()) {
|
||||
event.localRedactionEvent().on(MatrixEventEvent.Status, this.onAssociatedStatusChanged);
|
||||
}
|
||||
event.localRedactionEvent()?.on(MatrixEventEvent.Status, this.onAssociatedStatusChanged);
|
||||
const canRedact = room.currentState.maySendRedactionForEvent(event, userId);
|
||||
this.state = { canRedact, sendStatus: event.getAssociatedStatus() };
|
||||
}
|
||||
|
@ -121,9 +119,7 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
|
|||
unmountPills(this.pills);
|
||||
unmountTooltips(this.tooltips);
|
||||
const event = this.props.mxEvent;
|
||||
if (event.localRedactionEvent()) {
|
||||
event.localRedactionEvent().off(MatrixEventEvent.Status, this.onAssociatedStatusChanged);
|
||||
}
|
||||
event.localRedactionEvent()?.off(MatrixEventEvent.Status, this.onAssociatedStatusChanged);
|
||||
}
|
||||
|
||||
public componentDidUpdate(): void {
|
||||
|
@ -133,12 +129,12 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
|
|||
|
||||
private renderActionBar(): JSX.Element {
|
||||
// hide the button when already redacted
|
||||
let redactButton: JSX.Element;
|
||||
let redactButton: JSX.Element | undefined;
|
||||
if (!this.props.mxEvent.isRedacted() && !this.props.isBaseEvent && this.state.canRedact) {
|
||||
redactButton = <AccessibleButton onClick={this.onRedactClick}>{_t("Remove")}</AccessibleButton>;
|
||||
}
|
||||
|
||||
let viewSourceButton: JSX.Element;
|
||||
let viewSourceButton: JSX.Element | undefined;
|
||||
if (SettingsStore.getValue("developerMode")) {
|
||||
viewSourceButton = (
|
||||
<AccessibleButton onClick={this.onViewSourceClick}>{_t("View Source")}</AccessibleButton>
|
||||
|
@ -189,9 +185,8 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
|
|||
}
|
||||
|
||||
const timestamp = formatTime(new Date(mxEvent.getTs()), this.props.isTwelveHour);
|
||||
const isSending = ["sending", "queued", "encrypting"].indexOf(this.state.sendStatus) !== -1;
|
||||
const classes = classNames({
|
||||
mx_EventTile: true,
|
||||
const isSending = ["sending", "queued", "encrypting"].includes(this.state.sendStatus!);
|
||||
const classes = classNames("mx_EventTile", {
|
||||
// Note: we keep the `sending` state class for tests, not for our styles
|
||||
mx_EventTile_sending: isSending,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue