frontend: Make global notifications live-update on changes.

Fixes #2527
This commit is contained in:
Bojidar Marinov 2016-12-08 22:09:41 +02:00 committed by Tim Abbott
parent d28f1ddfb4
commit 8b44ace3a8
3 changed files with 31 additions and 6 deletions

View File

@ -329,19 +329,19 @@ var event_fixtures = {
update_display_settings__default_language: {
type: 'update_display_settings',
setting_name: 'default_language',
default_language: 'fr',
setting: 'fr',
},
update_display_settings__left_side_userlist: {
type: 'update_display_settings',
setting_name: 'left_side_userlist',
left_side_userlist: true,
setting: true,
},
update_display_settings__twenty_four_hour_time: {
type: 'update_display_settings',
setting_name: 'twenty_four_hour_time',
twenty_four_hour_time: true,
setting: true,
},
update_global_notifications: {

View File

@ -160,24 +160,30 @@ function dispatch_normal_event(event) {
case 'update_display_settings':
if (event.setting_name === 'twenty_four_hour_time') {
page_params.twenty_four_hour_time = event.twenty_four_hour_time;
page_params.twenty_four_hour_time = event.setting;
// TODO: Make this rerender the existing elements to not require a reload.
}
if (event.setting_name === 'left_side_userlist') {
// TODO: Make this change the view immediately rather
// than requiring a reload or page resize.
page_params.left_side_userlist = event.left_side_userlist;
page_params.left_side_userlist = event.setting;
}
if (event.setting_name === 'default_language') {
// TODO: Make this change the view immediately rather
// than requiring a reload or page resize.
page_params.default_language = event.default_language;
page_params.default_language = event.setting;
}
if ($("#settings.tab-pane.active").length) {
settings.update_page();
}
break;
case 'update_global_notifications':
notifications.handle_global_notification_updates(event.notification_name,
event.setting);
if ($("#settings.tab-pane.active").length) {
settings.update_page();
}
break;
case 'update_message_flags':

View File

@ -789,10 +789,29 @@ function _setup_page() {
});
}
function _update_page() {
$("#twenty_four_hour_time").prop('checked', page_params.twenty_four_hour_time);
$("#left_side_userlist").prop('checked', page_params.left_side_userlist);
$("#default_language_name").text(page_params.default_language_name);
$("#enable_stream_desktop_notifications").prop('checked', page_params.stream_desktop_notifications_enabled);
$("#enable_stream_sounds").prop('checked', page_params.stream_sounds_enabled);
$("#enable_desktop_notifications").prop('checked', page_params.desktop_notifications_enabled);
$("#enable_sounds").prop('checked', page_params.sounds_enabled);
$("#enable_offline_email_notifications").prop('checked', page_params.enable_offline_email_notifications);
$("#enable_offline_push_notifications").prop('checked', page_params.enable_offline_push_notifications);
$("#enable_online_push_notifications").prop('checked', page_params.enable_online_push_notifications);
$("#enable_digest_emails").prop('checked', page_params.enable_digest_emails);
}
exports.setup_page = function () {
i18n.ensure_i18n(_setup_page);
};
exports.update_page = function () {
i18n.ensure_i18n(_update_page);
};
return exports;
}());