From 241e0c12f0c9203b2ebb706d2ac8bc57b587f54d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 19 Jun 2020 15:45:48 -0600 Subject: [PATCH] Trigger room-specific watchers whenever a higher level change happens Otherwise the room list badges end up having to listen to `null` for a room ID, meaning they have to filter. The notification badge count setting is the first ever setting to watch based on a room ID, so there are no compatibility concerns with this change. --- src/settings/WatchManager.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/settings/WatchManager.js b/src/settings/WatchManager.js index 472b13966f..3f54ca929e 100644 --- a/src/settings/WatchManager.js +++ b/src/settings/WatchManager.js @@ -51,8 +51,17 @@ export class WatchManager { const roomWatchers = this._watchers[settingName]; const callbacks = []; - if (inRoomId !== null && roomWatchers[inRoomId]) callbacks.push(...roomWatchers[inRoomId]); - if (roomWatchers[null]) callbacks.push(...roomWatchers[null]); + if (inRoomId !== null && roomWatchers[inRoomId]) { + callbacks.push(...roomWatchers[inRoomId]); + } + + 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], [])); + } else if (roomWatchers[null]) { + callbacks.push(...roomWatchers[null]); + } for (const callback of callbacks) { callback(inRoomId, atLevel, newValueAtLevel);