notifications: Inline handle_global_notification_updates.

This commit is contained in:
Tim Abbott
2023-05-31 16:19:38 -07:00
parent b75964a6cc
commit c961ad4f37
4 changed files with 37 additions and 32 deletions

View File

@@ -646,13 +646,27 @@ export function dispatch_normal_event(event) {
break;
case "user_settings": {
if (settings_config.all_notification_settings.includes(event.property)) {
notifications.handle_global_notification_updates(event.property, event.value);
const notification_name = event.property;
if (settings_config.all_notification_settings.includes(notification_name)) {
// Update the global settings checked when determining if we should notify
// for a given message. These settings do not affect whether or not a
// particular stream should receive notifications.
user_settings[notification_name] = event.value;
if (settings_config.stream_notification_settings.includes(notification_name)) {
stream_ui_updates.update_notification_setting_checkbox(
settings_config.specialize_stream_notification_setting[notification_name],
);
}
if (notification_name === "notification_sound") {
// Change the sound source with the new page `notification_sound`.
notifications.update_notification_sound_source(
$("#user-notification-sound-audio"),
user_settings,
);
}
settings_notifications.update_page(settings_notifications.user_settings_panel);
// TODO: This should also do a refresh of the stream_edit UI
// if it's currently displayed, possibly reusing some code
// from stream_events.js
// (E.g. update_stream_push_notifications).
break;
}