Conform more code to strict null checking (#10167)
* Conform more code to strict null checking * Delint * Iterate PR based on feedback
This commit is contained in:
parent
f7bea2cae5
commit
4574c665ea
103 changed files with 517 additions and 495 deletions
|
@ -139,7 +139,7 @@ export const usePublicRoomDirectory = (): {
|
|||
SdkConfig.getObject("room_directory")?.get("servers")?.includes(lsRoomServer) ||
|
||||
SettingsStore.getValue("room_directory_servers")?.includes(lsRoomServer)
|
||||
) {
|
||||
roomServer = lsRoomServer;
|
||||
roomServer = lsRoomServer!;
|
||||
}
|
||||
|
||||
let instanceId: string | undefined = undefined;
|
||||
|
|
|
@ -19,7 +19,7 @@ import { useEffect, useState } from "react";
|
|||
import SettingsStore from "../settings/SettingsStore";
|
||||
|
||||
// Hook to fetch the value of a setting and dynamically update when it changes
|
||||
export const useSettingValue = <T>(settingName: string, roomId: string = null, excludeDefault = false): T => {
|
||||
export const useSettingValue = <T>(settingName: string, roomId: string | null = null, excludeDefault = false): T => {
|
||||
const [value, setValue] = useState(SettingsStore.getValue<T>(settingName, roomId, excludeDefault));
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -36,7 +36,7 @@ export const useSettingValue = <T>(settingName: string, roomId: string = null, e
|
|||
};
|
||||
|
||||
// Hook to fetch whether a feature is enabled and dynamically update when that changes
|
||||
export const useFeatureEnabled = (featureName: string, roomId: string = null): boolean => {
|
||||
export const useFeatureEnabled = (featureName: string, roomId: string | null = null): boolean => {
|
||||
const [enabled, setEnabled] = useState(SettingsStore.getValue<boolean>(featureName, roomId));
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -23,7 +23,7 @@ import { SlidingSyncManager } from "../SlidingSyncManager";
|
|||
|
||||
export interface SlidingSyncRoomSearchOpts {
|
||||
limit: number;
|
||||
query?: string;
|
||||
query: string;
|
||||
}
|
||||
|
||||
export const useSlidingSyncRoomSearch = (): {
|
||||
|
@ -55,7 +55,7 @@ export const useSlidingSyncRoomSearch = (): {
|
|||
room_name_like: term,
|
||||
},
|
||||
});
|
||||
const rooms = [];
|
||||
const rooms: Room[] = [];
|
||||
const { roomIndexToRoomId } = SlidingSyncManager.instance.slidingSync.getListData(
|
||||
SlidingSyncManager.ListSearch,
|
||||
)!;
|
||||
|
|
|
@ -31,7 +31,7 @@ export const useTimeout = (handler: Handler, timeoutMs: number): void => {
|
|||
// Set up timer
|
||||
useEffect(() => {
|
||||
const timeoutID = window.setTimeout(() => {
|
||||
savedHandler.current();
|
||||
savedHandler.current?.();
|
||||
}, timeoutMs);
|
||||
return () => clearTimeout(timeoutID);
|
||||
}, [timeoutMs]);
|
||||
|
@ -50,7 +50,7 @@ export const useInterval = (handler: Handler, intervalMs: number): void => {
|
|||
// Set up timer
|
||||
useEffect(() => {
|
||||
const intervalID = window.setInterval(() => {
|
||||
savedHandler.current();
|
||||
savedHandler.current?.();
|
||||
}, intervalMs);
|
||||
return () => clearInterval(intervalID);
|
||||
}, [intervalMs]);
|
||||
|
|
|
@ -22,7 +22,7 @@ import { useLatestResult } from "./useLatestResult";
|
|||
|
||||
export interface IUserDirectoryOpts {
|
||||
limit: number;
|
||||
query?: string;
|
||||
query: string;
|
||||
}
|
||||
|
||||
export const useUserDirectory = (): {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue