Conform more of the codebase to strictNullChecks (#10672)
* Conform more of the codebase to `strictNullChecks` * Iterate * Iterate * Iterate * Iterate * Conform more of the codebase to `strictNullChecks` * Iterate * Update record key
This commit is contained in:
@@ -87,7 +87,7 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
|
||||
await this.updateState({ enabled: SettingsStore.getValue("breadcrumbs", null) });
|
||||
}
|
||||
} else if (payload.action === Action.ViewRoom) {
|
||||
if (payload.auto_join && !this.matrixClient.getRoom(payload.room_id)) {
|
||||
if (payload.auto_join && payload.room_id && !this.matrixClient.getRoom(payload.room_id)) {
|
||||
// Queue the room instead of pushing it immediately. We're probably just
|
||||
// waiting for a room join to complete.
|
||||
this.waitingRooms.push({ roomId: payload.room_id, addedTs: Date.now() });
|
||||
|
||||
@@ -426,6 +426,7 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
||||
roomId: Room["roomId"],
|
||||
beaconInfoContent: MBeaconInfoEventContent,
|
||||
): Promise<void> => {
|
||||
if (!this.matrixClient) return;
|
||||
// explicitly stop any live beacons this user has
|
||||
// to ensure they remain stopped
|
||||
// if the new replacing beacon is redacted
|
||||
@@ -435,7 +436,7 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
||||
// eslint-disable-next-line camelcase
|
||||
const { event_id } = await doMaybeLocalRoomAction(
|
||||
roomId,
|
||||
(actualRoomId: string) => this.matrixClient.unstable_createLiveBeacon(actualRoomId, beaconInfoContent),
|
||||
(actualRoomId: string) => this.matrixClient!.unstable_createLiveBeacon(actualRoomId, beaconInfoContent),
|
||||
this.matrixClient,
|
||||
);
|
||||
|
||||
@@ -552,7 +553,7 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
||||
const updateContent = makeBeaconInfoContent(timeout, live, description, assetType, timestamp);
|
||||
|
||||
try {
|
||||
await this.matrixClient.unstable_setLiveBeacon(beacon.roomId, updateContent);
|
||||
await this.matrixClient!.unstable_setLiveBeacon(beacon.roomId, updateContent);
|
||||
// cleanup any errors
|
||||
const hadError = this.beaconUpdateErrors.has(beacon.identifier);
|
||||
if (hadError) {
|
||||
@@ -576,7 +577,7 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
||||
this.lastPublishedPositionTimestamp = Date.now();
|
||||
await Promise.all(
|
||||
this.healthyLiveBeaconIds.map((beaconId) =>
|
||||
this.sendLocationToBeacon(this.beacons.get(beaconId), position),
|
||||
this.beacons.has(beaconId) ? this.sendLocationToBeacon(this.beacons.get(beaconId)!, position) : null,
|
||||
),
|
||||
);
|
||||
};
|
||||
@@ -589,7 +590,7 @@ export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
||||
private sendLocationToBeacon = async (beacon: Beacon, { geoUri, timestamp }: TimedGeoUri): Promise<void> => {
|
||||
const content = makeBeaconContent(geoUri, timestamp, beacon.beaconInfoId);
|
||||
try {
|
||||
await this.matrixClient.sendEvent(beacon.roomId, M_BEACON.name, content);
|
||||
await this.matrixClient!.sendEvent(beacon.roomId, M_BEACON.name, content);
|
||||
this.incrementBeaconLocationPublishErrorCount(beacon.identifier, false);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
|
||||
@@ -27,7 +27,7 @@ export enum CachedRoomKey {
|
||||
NotificationVolume,
|
||||
}
|
||||
|
||||
export class RoomEchoChamber extends GenericEchoChamber<RoomEchoContext, CachedRoomKey, RoomNotifState> {
|
||||
export class RoomEchoChamber extends GenericEchoChamber<RoomEchoContext, CachedRoomKey, RoomNotifState | undefined> {
|
||||
private properties = new Map<CachedRoomKey, RoomNotifState>();
|
||||
|
||||
public constructor(context: RoomEchoContext) {
|
||||
@@ -67,11 +67,12 @@ export class RoomEchoChamber extends GenericEchoChamber<RoomEchoContext, CachedR
|
||||
|
||||
// ---- helpers below here ----
|
||||
|
||||
public get notificationVolume(): RoomNotifState {
|
||||
public get notificationVolume(): RoomNotifState | undefined {
|
||||
return this.getValue(CachedRoomKey.NotificationVolume);
|
||||
}
|
||||
|
||||
public set notificationVolume(v: RoomNotifState) {
|
||||
public set notificationVolume(v: RoomNotifState | undefined) {
|
||||
if (v === undefined) return;
|
||||
this.setValue(
|
||||
_t("Change notification settings"),
|
||||
CachedRoomKey.NotificationVolume,
|
||||
|
||||
@@ -307,7 +307,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||
|
||||
public fetchSuggestedRooms = async (space: Room, limit = MAX_SUGGESTED_ROOMS): Promise<ISuggestedRoom[]> => {
|
||||
try {
|
||||
const { rooms } = await this.matrixClient.getRoomHierarchy(space.roomId, limit, 1, true);
|
||||
const { rooms } = await this.matrixClient!.getRoomHierarchy(space.roomId, limit, 1, true);
|
||||
|
||||
const viaMap = new EnhancedMap<string, Set<string>>();
|
||||
rooms.forEach((room) => {
|
||||
@@ -979,7 +979,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||
private onRoomState = (ev: MatrixEvent): void => {
|
||||
const room = this.matrixClient?.getRoom(ev.getRoomId());
|
||||
|
||||
if (!room) return;
|
||||
if (!this.matrixClient || !room) return;
|
||||
|
||||
switch (ev.getType()) {
|
||||
case EventType.SpaceChild: {
|
||||
|
||||
@@ -274,19 +274,22 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
||||
await Promise.all(
|
||||
Object.entries(contentMap).flatMap(([userId, userContentMap]) =>
|
||||
Object.entries(userContentMap).map(async ([deviceId, content]): Promise<void> => {
|
||||
const devices = deviceInfoMap.get(userId);
|
||||
if (!devices) return;
|
||||
|
||||
if (deviceId === "*") {
|
||||
// Send the message to all devices we have keys for
|
||||
await client.encryptAndSendToDevices(
|
||||
Array.from(deviceInfoMap.get(userId).values()).map((deviceInfo) => ({
|
||||
Array.from(devices.values()).map((deviceInfo) => ({
|
||||
userId,
|
||||
deviceInfo,
|
||||
})),
|
||||
content,
|
||||
);
|
||||
} else {
|
||||
} else if (devices.has(deviceId)) {
|
||||
// Send the message to a specific device
|
||||
await client.encryptAndSendToDevices(
|
||||
[{ userId, deviceInfo: deviceInfoMap.get(userId).get(deviceId) }],
|
||||
[{ userId, deviceInfo: devices.get(deviceId)! }],
|
||||
content,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
||||
}
|
||||
|
||||
public getContainerWidgets(room: Optional<Room>, container: Container): IApp[] {
|
||||
return this.byRoom.get(room?.roomId)?.get(container)?.ordered || [];
|
||||
return (room && this.byRoom.get(room.roomId)?.get(container)?.ordered) || [];
|
||||
}
|
||||
|
||||
public isInContainer(room: Room, widget: IApp, container: Container): boolean {
|
||||
|
||||
@@ -58,7 +58,7 @@ export class WidgetPermissionStore {
|
||||
return OIDCState.Unknown;
|
||||
}
|
||||
|
||||
public setOIDCState(widget: Widget, kind: WidgetKind, roomId: string, newState: OIDCState): void {
|
||||
public setOIDCState(widget: Widget, kind: WidgetKind, roomId: string | undefined, newState: OIDCState): void {
|
||||
const settingsKey = this.packSettingKey(widget, kind, roomId);
|
||||
|
||||
let currentValues = SettingsStore.getValue<{
|
||||
|
||||
Reference in New Issue
Block a user