Add an option to play audio notifications

This commit is contained in:
Asa Ayers 2017-01-28 11:33:57 -08:00
parent b9c8b4afbb
commit bda0430805
5 changed files with 22 additions and 0 deletions

View file

@ -12,6 +12,8 @@
MESSAGE : 'message'
};
var sound = new Audio('/audio/NewMessage.mp3');
Whisper.Notifications = new (Backbone.Collection.extend({
initialize: function() {
this.on('add', _.debounce(this.update.bind(this), 1000));
@ -35,6 +37,11 @@
if (this.length === 0) {
return;
}
var audioNotification = storage.get('audio-notification') || false;
if (audioNotification) {
sound.play();
}
var setting = storage.get('notification-setting') || 'message';
if (setting === SETTINGS.OFF) {
return;

View file

@ -59,6 +59,11 @@
defaultValue: 'android',
name: 'theme-setting'
});
new CheckboxView({
el: this.$('.audio-notification-setting'),
defaultValue: false,
name: 'audio-notification'
});
new CheckboxView({
el: this.$('.safety-numbers-settings'),
defaultValue: true,
@ -84,6 +89,7 @@
nameOnly: i18n('nameOnly'),
safetyNumbersSettingDescription: i18n('safetyNumbersSettingDescription'),
safetyNumbersSettingHeader: i18n('safetyNumbersSettingHeader'),
audioNotificationDescription: i18n('audioNotificationDescription'),
themeAndroidDark: i18n('themeAndroidDark'),
};
}