Conform more of the codebase to strictNullChecks
(#10666)
* Conform more of the codebase to `strictNullChecks` * Iterate * Iterate * Iterate * Iterate
This commit is contained in:
parent
8867f1801e
commit
93b4ee654b
17 changed files with 126 additions and 114 deletions
|
@ -99,7 +99,7 @@ export default class MessageComposerFormatBar extends React.PureComponent<IProps
|
|||
}
|
||||
|
||||
public showAt(selectionRect: DOMRect): void {
|
||||
if (!this.formatBarRef.current) return;
|
||||
if (!this.formatBarRef.current?.parentElement) return;
|
||||
|
||||
this.setState({ visible: true });
|
||||
const parentRect = this.formatBarRef.current.parentElement.getBoundingClientRect();
|
||||
|
|
|
@ -216,7 +216,7 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
|
|||
return {};
|
||||
}
|
||||
const kickerMember = this.props.room?.currentState.getMember(myMember.events.member.getSender());
|
||||
const memberName = kickerMember ? kickerMember.name : myMember.events.member.getSender();
|
||||
const memberName = kickerMember?.name ?? myMember.events.member?.getSender();
|
||||
const reason = myMember.events.member?.getContent().reason;
|
||||
return { memberName, reason };
|
||||
}
|
||||
|
|
|
@ -433,9 +433,11 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
};
|
||||
|
||||
private onHeaderClick = (): void => {
|
||||
const possibleSticky = this.headerButton.current.parentElement;
|
||||
const sublist = possibleSticky.parentElement.parentElement;
|
||||
const list = sublist.parentElement.parentElement;
|
||||
const possibleSticky = this.headerButton.current?.parentElement;
|
||||
const sublist = possibleSticky?.parentElement?.parentElement;
|
||||
const list = sublist?.parentElement?.parentElement;
|
||||
if (!possibleSticky || !list) return;
|
||||
|
||||
// the scrollTop is capped at the height of the header in LeftPanel, the top header is always sticky
|
||||
const listScrollTop = Math.round(list.scrollTop);
|
||||
const isAtTop = listScrollTop <= Math.round(HEADER_HEIGHT);
|
||||
|
|
|
@ -91,7 +91,7 @@ export default class WhoIsTypingTile extends React.Component<IProps, IState> {
|
|||
|
||||
private onRoomTimeline = (event: MatrixEvent, room?: Room): void => {
|
||||
if (room?.roomId === this.props.room.roomId) {
|
||||
const userId = event.getSender();
|
||||
const userId = event.getSender()!;
|
||||
// remove user from usersTyping
|
||||
const usersTyping = this.state.usersTyping.filter((m) => m.userId !== userId);
|
||||
if (usersTyping.length !== this.state.usersTyping.length) {
|
||||
|
@ -200,14 +200,15 @@ export default class WhoIsTypingTile extends React.Component<IProps, IState> {
|
|||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
let usersTyping = this.state.usersTyping;
|
||||
const stoppedUsersOnTimer = Object.keys(this.state.delayedStopTypingTimers).map((userId) =>
|
||||
this.props.room.getMember(userId),
|
||||
);
|
||||
const usersTyping = this.state.usersTyping;
|
||||
// append the users that have been reported not typing anymore
|
||||
// but have a timeout timer running so they can disappear
|
||||
// when a message comes in
|
||||
usersTyping = usersTyping.concat(stoppedUsersOnTimer);
|
||||
for (const userId in this.state.delayedStopTypingTimers) {
|
||||
const member = this.props.room.getMember(userId);
|
||||
if (member) usersTyping.push(member);
|
||||
}
|
||||
|
||||
// sort them so the typing members don't change order when
|
||||
// moved to delayedStopTypingTimers
|
||||
usersTyping.sort((a, b) => compare(a.name, b.name));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue