Apply strictNullChecks to src/async-components/* (#10251

* Apply strictNullChecks to src/async-components/*

* Iterate
This commit is contained in:
Michael Telatyński 2023-02-28 10:51:27 +00:00 committed by GitHub
parent 629e5cb01f
commit 8ad21e6492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 43 deletions

View file

@ -38,7 +38,7 @@ interface IState {
eventCount: number;
crawlingRoomsCount: number;
roomCount: number;
currentRoom: string;
currentRoom: string | null;
crawlerSleepTime: number;
}
@ -61,7 +61,8 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta
public updateCurrentRoom = async (room: Room): Promise<void> => {
const eventIndex = EventIndexPeg.get();
let stats: IIndexStats;
if (!eventIndex) return;
let stats: IIndexStats | undefined;
try {
stats = await eventIndex.getStats();
@ -71,7 +72,7 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta
return;
}
let currentRoom = null;
let currentRoom: string | null = null;
if (room) currentRoom = room.name;
const roomStats = eventIndex.crawlingRooms();
@ -79,8 +80,8 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta
const roomCount = roomStats.totalRooms.size;
this.setState({
eventIndexSize: stats.size,
eventCount: stats.eventCount,
eventIndexSize: stats?.size ?? 0,
eventCount: stats?.eventCount ?? 0,
crawlingRoomsCount: crawlingRoomsCount,
roomCount: roomCount,
currentRoom: currentRoom,
@ -100,7 +101,7 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta
let crawlingRoomsCount = 0;
let roomCount = 0;
let eventCount = 0;
let currentRoom = null;
let currentRoom: string | null = null;
const eventIndex = EventIndexPeg.get();
@ -109,8 +110,10 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta
try {
const stats = await eventIndex.getStats();
eventIndexSize = stats.size;
eventCount = stats.eventCount;
if (stats) {
eventIndexSize = stats.size;
eventCount = stats.eventCount;
}
} catch {
// This call may fail if sporadically, not a huge issue as we
// will try later again in the updateCurrentRoom call and
@ -136,7 +139,7 @@ export default class ManageEventIndexDialog extends React.Component<IProps, ISta
private onDisable = async (): Promise<void> => {
const DisableEventIndexDialog = (await import("./DisableEventIndexDialog")).default;
Modal.createDialog(DisableEventIndexDialog, null, null, /* priority = */ false, /* static = */ true);
Modal.createDialog(DisableEventIndexDialog, undefined, undefined, /* priority = */ false, /* static = */ true);
};
private onCrawlerSleepTimeChange = (e: ChangeEvent<HTMLInputElement>): void => {