mirror of https://github.com/vector-im/riot-web
Make the controller work for notifications
Signed-off-by: Travis Ralston <travpc@gmail.com>pull/21833/head
parent
7ce4316cc8
commit
e31c89d360
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue