Make the controller work for notifications

Signed-off-by: Travis Ralston <travpc@gmail.com>
pull/21833/head
Travis Ralston 2017-11-04 22:28:35 -07:00
parent 7ce4316cc8
commit e31c89d360
3 changed files with 44 additions and 39 deletions

View File

@ -15,6 +15,11 @@ limitations under the License.
*/ */
import {_td} from '../languageHandler'; 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 // These are just a bunch of helper arrays to avoid copy/pasting a bunch of times
@ -219,17 +224,17 @@ export const SETTINGS = {
"notificationsEnabled": { "notificationsEnabled": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false, default: false,
//controller: new NotificationsEnabledController(), controller: new NotificationsEnabledController(),
}, },
"notificationBodyEnabled": { "notificationBodyEnabled": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false, default: true,
//controller: new NotificationBodyEnabledController(), controller: new NotificationBodyEnabledController(),
}, },
"audioNotificationsEnabled": { "audioNotificationsEnabled": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
default: false, default: true,
//controller: new AudioNotificationsEnabledController(), controller: new AudioNotificationsEnabledController(),
}, },
"notificationToolbarHidden": { "notificationToolbarHidden": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS, supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,

View File

@ -261,11 +261,11 @@ export default class SettingsStore {
throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId); 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; const controller = SETTINGS[settingName].controller;
if (!controller) return; if (!controller) return;
controller.onChange(level, roomId, value); controller.onChange(level, roomId, value);
})); });
} }
/** /**

View File

@ -14,36 +14,36 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
//import SettingController from "./SettingController"; import SettingController from "./SettingController";
// export class NotificationsEnabledController extends SettingController { export class NotificationsEnabledController extends SettingController {
// getValueOverride(level, roomId, calculatedValue) { getValueOverride(level, roomId, calculatedValue) {
// const Notifier = require('../../Notifier'); // avoids cyclical references const Notifier = require('../../Notifier'); // avoids cyclical references
//
// return calculatedValue && Notifier.isPossible(); return calculatedValue && Notifier.isPossible();
// } }
//
// onChange(level, roomId, newValue) { onChange(level, roomId, newValue) {
// const Notifier = require('../../Notifier'); // avoids cyclical references const Notifier = require('../../Notifier'); // avoids cyclical references
//
// if (Notifier.supportsDesktopNotifications()) { if (Notifier.supportsDesktopNotifications()) {
// Notifier.setBodyEnabled(newValue); Notifier.setEnabled(newValue);
// } }
// } }
// } }
//
// export class NotificationBodyEnabledController extends SettingController { export class NotificationBodyEnabledController extends SettingController {
// getValueOverride(level, roomId, calculatedValue) { getValueOverride(level, roomId, calculatedValue) {
// const Notifier = require('../../Notifier'); // avoids cyclical references const Notifier = require('../../Notifier'); // avoids cyclical references
//
// return calculatedValue && Notifier.isEnabled(); return calculatedValue && Notifier.isEnabled();
// } }
// } }
//
// export class AudioNotificationsEnabledController extends SettingController { export class AudioNotificationsEnabledController extends SettingController {
// getValueOverride(level, roomId, calculatedValue) { getValueOverride(level, roomId, calculatedValue) {
// const Notifier = require('../../Notifier'); // avoids cyclical references const Notifier = require('../../Notifier'); // avoids cyclical references
//
// return calculatedValue && Notifier.isEnabled(); return calculatedValue && Notifier.isEnabled();
// } }
// } }