From 07f7ff6831f84ac23b94f2742581659ba3d918a9 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 8 Sep 2020 11:01:36 +0100 Subject: [PATCH] Fix WatchManager global room watchers --- src/settings/WatchManager.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/settings/WatchManager.ts b/src/settings/WatchManager.ts index d51439459c..925a99f2dc 100644 --- a/src/settings/WatchManager.ts +++ b/src/settings/WatchManager.ts @@ -18,11 +18,10 @@ import { SettingLevel } from "./SettingLevel"; export type CallbackFn = (changedInRoomId: string, atLevel: SettingLevel, newValAtLevel: any) => void; -const IRRELEVANT_ROOM = Symbol("any room"); +const IRRELEVANT_ROOM = String(null); interface RoomWatcherMap { - // @ts-ignore - TS wants string-only keys but we know better - https://github.com/Microsoft/TypeScript/issues/1863 - [roomId: string | symbol]: CallbackFn[]; + [roomId: string]: CallbackFn[]; } /** @@ -69,7 +68,7 @@ export class WatchManager { if (!inRoomId) { // Fire updates to all the individual room watchers too, as they probably // care about the change higher up. - callbacks.push(...Object.values(roomWatchers).reduce((r, a) => [...r, ...a], [])); + callbacks.push(...Object.values(roomWatchers).flat(1)); } else if (roomWatchers[IRRELEVANT_ROOM]) { callbacks.push(...roomWatchers[IRRELEVANT_ROOM]); }