Make more code conform to strict null checks (#10219

* Make more code conform to strict null checks

* Fix types

* Fix tests

* Fix remaining test assertions

* Iterate PR
This commit is contained in:
Michael Telatynski
2023-02-24 15:28:40 +00:00
committed by GitHub
parent 4c79ecf141
commit 76b82b4b2b
130 changed files with 603 additions and 603 deletions
+6 -6
View File
@@ -99,7 +99,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
[roomId: string]: Partial<{
[container in Container]: {
ordered: IApp[];
height?: number;
height?: number | null;
distributions?: number[];
};
}>;
@@ -402,11 +402,11 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
this.updateUserLayout(room, localLayout);
}
public getContainerHeight(room: Room, container: Container): number {
return this.byRoom[room.roomId]?.[container]?.height; // let the default get returned if needed
public getContainerHeight(room: Room, container: Container): number | null {
return this.byRoom[room.roomId]?.[container]?.height ?? null; // let the default get returned if needed
}
public setContainerHeight(room: Room, container: Container, height: number): void {
public setContainerHeight(room: Room, container: Container, height?: number): void {
const widgets = this.getContainerWidgets(room, container);
const widths = this.byRoom[room.roomId]?.[container]?.distributions;
const localLayout: Record<string, IStoredLayout> = {};
@@ -502,8 +502,8 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
const height = this.byRoom[room.roomId]?.[container]?.height;
evContent.widgets[widget.id] = {
...evContent.widgets[widget.id],
height: height ? Math.round(height) : null,
width: widths[idx] ? Math.round(widths[idx]) : null,
height: height ? Math.round(height) : undefined,
width: widths?.[idx] ? Math.round(widths[idx]) : undefined,
index: idx,
};
}