diff --git a/src/settings/Settings.js b/src/settings/Settings.js index a166e8e199..ef8f9ae259 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -15,6 +15,11 @@ limitations under the License. */ import {_td} from '../languageHandler'; +import { + AudioNotificationsEnabledController, + NotificationBodyEnabledController, + NotificationsEnabledController, +} from "./controllers/NotificationControllers"; // These are just a bunch of helper arrays to avoid copy/pasting a bunch of times @@ -219,17 +224,17 @@ export const SETTINGS = { "notificationsEnabled": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, default: false, - //controller: new NotificationsEnabledController(), + controller: new NotificationsEnabledController(), }, "notificationBodyEnabled": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, - default: false, - //controller: new NotificationBodyEnabledController(), + default: true, + controller: new NotificationBodyEnabledController(), }, "audioNotificationsEnabled": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, - default: false, - //controller: new AudioNotificationsEnabledController(), + default: true, + controller: new AudioNotificationsEnabledController(), }, "notificationToolbarHidden": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, diff --git a/src/settings/SettingsStore.js b/src/settings/SettingsStore.js index a65943b927..88783613b2 100644 --- a/src/settings/SettingsStore.js +++ b/src/settings/SettingsStore.js @@ -261,11 +261,11 @@ export default class SettingsStore { throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId); } - return handler.setValue(settingName, roomId, value).finally((() => { + return handler.setValue(settingName, roomId, value).finally(() => { const controller = SETTINGS[settingName].controller; if (!controller) return; controller.onChange(level, roomId, value); - })); + }); } /** diff --git a/src/settings/controllers/NotificationControllers.js b/src/settings/controllers/NotificationControllers.js index 1c2c673136..261e194d74 100644 --- a/src/settings/controllers/NotificationControllers.js +++ b/src/settings/controllers/NotificationControllers.js @@ -14,36 +14,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -//import SettingController from "./SettingController"; +import SettingController from "./SettingController"; -// export class NotificationsEnabledController extends SettingController { -// getValueOverride(level, roomId, calculatedValue) { -// const Notifier = require('../../Notifier'); // avoids cyclical references -// -// return calculatedValue && Notifier.isPossible(); -// } -// -// onChange(level, roomId, newValue) { -// const Notifier = require('../../Notifier'); // avoids cyclical references -// -// if (Notifier.supportsDesktopNotifications()) { -// Notifier.setBodyEnabled(newValue); -// } -// } -// } -// -// export class NotificationBodyEnabledController extends SettingController { -// getValueOverride(level, roomId, calculatedValue) { -// const Notifier = require('../../Notifier'); // avoids cyclical references -// -// return calculatedValue && Notifier.isEnabled(); -// } -// } -// -// export class AudioNotificationsEnabledController extends SettingController { -// getValueOverride(level, roomId, calculatedValue) { -// const Notifier = require('../../Notifier'); // avoids cyclical references -// -// return calculatedValue && Notifier.isEnabled(); -// } -// } +export class NotificationsEnabledController extends SettingController { + getValueOverride(level, roomId, calculatedValue) { + const Notifier = require('../../Notifier'); // avoids cyclical references + + return calculatedValue && Notifier.isPossible(); + } + + onChange(level, roomId, newValue) { + const Notifier = require('../../Notifier'); // avoids cyclical references + + if (Notifier.supportsDesktopNotifications()) { + Notifier.setEnabled(newValue); + } + } +} + +export class NotificationBodyEnabledController extends SettingController { + getValueOverride(level, roomId, calculatedValue) { + const Notifier = require('../../Notifier'); // avoids cyclical references + + return calculatedValue && Notifier.isEnabled(); + } +} + +export class AudioNotificationsEnabledController extends SettingController { + getValueOverride(level, roomId, calculatedValue) { + const Notifier = require('../../Notifier'); // avoids cyclical references + + return calculatedValue && Notifier.isEnabled(); + } +}