diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index dd15937d98..928e739649 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -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: { diff --git a/static/js/server_events.js b/static/js/server_events.js index db2ae6795f..a78d9d7d47 100644 --- a/static/js/server_events.js +++ b/static/js/server_events.js @@ -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': diff --git a/static/js/settings.js b/static/js/settings.js index 27c4835955..199c4decac 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -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; }());