diff --git a/src/settings/SettingsStore.js b/src/settings/SettingsStore.js index d93a48005d..a1b88fb0c2 100644 --- a/src/settings/SettingsStore.js +++ b/src/settings/SettingsStore.js @@ -222,9 +222,9 @@ export default class SettingsStore { if (explicit) { const handler = handlers[level]; - if (!handler) return SettingsStore._tryControllerOverride(settingName, level, roomId, null); + if (!handler) return SettingsStore._tryControllerOverride(settingName, level, roomId, null, null); const value = handler.getValue(settingName, roomId); - return SettingsStore._tryControllerOverride(settingName, level, roomId, value); + return SettingsStore._tryControllerOverride(settingName, level, roomId, value, level); } for (let i = minIndex; i < levelOrder.length; i++) { @@ -234,17 +234,17 @@ export default class SettingsStore { const value = handler.getValue(settingName, roomId); if (value === null || value === undefined) continue; - return SettingsStore._tryControllerOverride(settingName, level, roomId, value); + return SettingsStore._tryControllerOverride(settingName, level, roomId, value, levelOrder[i]); } - return SettingsStore._tryControllerOverride(settingName, level, roomId, null); + return SettingsStore._tryControllerOverride(settingName, level, roomId, null, null); } - static _tryControllerOverride(settingName, level, roomId, calculatedValue) { + static _tryControllerOverride(settingName, level, roomId, calculatedValue, calculatedAtLevel) { const controller = SETTINGS[settingName].controller; if (!controller) return calculatedValue; - const actualValue = controller.getValueOverride(level, roomId, calculatedValue); + const actualValue = controller.getValueOverride(level, roomId, calculatedValue, calculatedAtLevel); if (actualValue !== undefined && actualValue !== null) return actualValue; return calculatedValue; } diff --git a/src/settings/controllers/NotificationControllers.js b/src/settings/controllers/NotificationControllers.js index 9dcf78e26b..e78b67e847 100644 --- a/src/settings/controllers/NotificationControllers.js +++ b/src/settings/controllers/NotificationControllers.js @@ -35,11 +35,11 @@ function isMasterRuleEnabled() { } export class NotificationsEnabledController extends SettingController { - getValueOverride(level, roomId, calculatedValue) { + getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) { const Notifier = require('../../Notifier'); // avoids cyclical references if (!Notifier.isPossible()) return false; - if (calculatedValue === null) { + if (calculatedValue === null || calculatedAtLevel === "default") { return isMasterRuleEnabled(); } diff --git a/src/settings/controllers/SettingController.js b/src/settings/controllers/SettingController.js index a91b616da9..0ebe0042e6 100644 --- a/src/settings/controllers/SettingController.js +++ b/src/settings/controllers/SettingController.js @@ -31,9 +31,11 @@ export default class SettingController { * @param {String} roomId The room ID, may be null. * @param {*} calculatedValue The value that the handlers think the setting should be, * may be null. + * @param {string} calculatedAtLevel The level for which the calculated value was + * calculated at. May be null. * @return {*} The value that should be used, or null if no override is applicable. */ - getValueOverride(level, roomId, calculatedValue) { + getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) { return null; // no override }