Apply strictNullChecks to src/components/views/avatars/* (#10254)
This commit is contained in:
parent
eca28ac2f3
commit
ae5725b24c
7 changed files with 41 additions and 31 deletions
|
@ -62,7 +62,7 @@ enum Icon {
|
|||
PresenceBusy = "BUSY",
|
||||
}
|
||||
|
||||
function tooltipText(variant: Icon): string {
|
||||
function tooltipText(variant: Icon): string | undefined {
|
||||
switch (variant) {
|
||||
case Icon.Globe:
|
||||
return _t("This room is public");
|
||||
|
@ -78,7 +78,7 @@ function tooltipText(variant: Icon): string {
|
|||
}
|
||||
|
||||
export default class DecoratedRoomAvatar extends React.PureComponent<IProps, IState> {
|
||||
private _dmUser: User;
|
||||
private _dmUser: User | null;
|
||||
private isUnmounted = false;
|
||||
private isWatchingTimeline = false;
|
||||
|
||||
|
@ -103,11 +103,11 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
|
|||
return joinRule === JoinRule.Public;
|
||||
}
|
||||
|
||||
private get dmUser(): User {
|
||||
private get dmUser(): User | null {
|
||||
return this._dmUser;
|
||||
}
|
||||
|
||||
private set dmUser(val: User) {
|
||||
private set dmUser(val: User | null) {
|
||||
const oldUser = this._dmUser;
|
||||
this._dmUser = val;
|
||||
if (oldUser && oldUser !== this._dmUser) {
|
||||
|
@ -120,7 +120,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
|
|||
}
|
||||
}
|
||||
|
||||
private onRoomTimeline = (ev: MatrixEvent, room: Room | null): void => {
|
||||
private onRoomTimeline = (ev: MatrixEvent, room?: Room): void => {
|
||||
if (this.isUnmounted) return;
|
||||
if (this.props.room.roomId !== room?.roomId) return;
|
||||
|
||||
|
@ -182,7 +182,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
|
|||
|
||||
public render(): React.ReactNode {
|
||||
let badge: React.ReactNode;
|
||||
if (this.props.displayBadge) {
|
||||
if (this.props.displayBadge && this.state.notificationState) {
|
||||
badge = (
|
||||
<NotificationBadge
|
||||
notification={this.state.notificationState}
|
||||
|
@ -192,7 +192,7 @@ export default class DecoratedRoomAvatar extends React.PureComponent<IProps, ISt
|
|||
);
|
||||
}
|
||||
|
||||
let icon;
|
||||
let icon: JSX.Element | undefined;
|
||||
if (this.state.icon !== Icon.None) {
|
||||
icon = (
|
||||
<TextWithTooltip
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue