Notification sounds (#367)
* Basic notification sound support * Add settings option for notification sounds * Allow sound without desktop notifications
This commit is contained in:
@@ -29,6 +29,7 @@ class Settings extends EventEmitter {
|
||||
this.hideMembershipEvents = this.getHideMembershipEvents();
|
||||
this.hideNickAvatarEvents = this.getHideNickAvatarEvents();
|
||||
this._showNotifications = this.getShowNotifications();
|
||||
this.isNotificationSounds = this.getIsNotificationSounds();
|
||||
|
||||
this.isTouchScreenDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0);
|
||||
}
|
||||
@@ -125,6 +126,15 @@ class Settings extends EventEmitter {
|
||||
return settings.showNotifications;
|
||||
}
|
||||
|
||||
getIsNotificationSounds() {
|
||||
if (typeof this.isNotificationSounds === 'boolean') return this.isNotificationSounds;
|
||||
|
||||
const settings = getSettings();
|
||||
if (settings === null) return true;
|
||||
if (typeof settings.isNotificationSounds === 'undefined') return true;
|
||||
return settings.isNotificationSounds;
|
||||
}
|
||||
|
||||
setter(action) {
|
||||
const actions = {
|
||||
[cons.actions.settings.TOGGLE_SYSTEM_THEME]: () => {
|
||||
@@ -164,6 +174,11 @@ class Settings extends EventEmitter {
|
||||
setSettings('showNotifications', this._showNotifications);
|
||||
this.emit(cons.events.settings.NOTIFICATIONS_TOGGLED, this._showNotifications);
|
||||
},
|
||||
[cons.actions.settings.TOGGLE_NOTIFICATION_SOUNDS]: () => {
|
||||
this.isNotificationSounds = !this.isNotificationSounds;
|
||||
setSettings('isNotificationSounds', this.isNotificationSounds);
|
||||
this.emit(cons.events.settings.NOTIFICATION_SOUNDS_TOGGLED, this.isNotificationSounds);
|
||||
},
|
||||
};
|
||||
|
||||
actions[action.type]?.();
|
||||
|
||||
Reference in New Issue
Block a user