Conform more of the codebase to strictNullChecks (#10738)

This commit is contained in:
Michael Telatynski 2023-05-09 18:24:40 +01:00 committed by GitHub
parent 5e8488c283
commit 52017f62e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 105 additions and 84 deletions

View file

@ -23,11 +23,13 @@ import { PROPERTY_UPDATED } from "../stores/local-echo/GenericEchoChamber";
import { CachedRoomKey } from "../stores/local-echo/RoomEchoChamber";
import { useEventEmitter } from "./useEventEmitter";
export const useNotificationState = (room: Room): [RoomNotifState, (state: RoomNotifState) => void] => {
export const useNotificationState = (room: Room): [RoomNotifState | undefined, (state: RoomNotifState) => void] => {
const echoChamber = useMemo(() => EchoChamber.forRoom(room), [room]);
const [notificationState, setNotificationState] = useState<RoomNotifState>(echoChamber.notificationVolume);
const [notificationState, setNotificationState] = useState<RoomNotifState | undefined>(
echoChamber.notificationVolume,
);
useEventEmitter(echoChamber, PROPERTY_UPDATED, (key: CachedRoomKey) => {
if (key === CachedRoomKey.NotificationVolume) {
if (key === CachedRoomKey.NotificationVolume && echoChamber.notificationVolume !== undefined) {
setNotificationState(echoChamber.notificationVolume);
}
});