From 49232d917360a2f77ef531c3d7977f61d1d2e205 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 27 Sep 2013 13:38:56 -0400 Subject: [PATCH] Preserve muting preferences across reloads. We have been persisting muting preferences on the back end for a while, but we haven't been adding them to page_params for the client to have at reload/startup time. (imported from commit d9ca68aa0e4d22bfb0e6ce67fc0bc63981175c8b) --- static/js/muting_ui.js | 4 ++++ zerver/lib/actions.py | 2 ++ zerver/views/__init__.py | 1 + 3 files changed, 7 insertions(+) diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js index b6051859e0..e53ecf48fe 100644 --- a/static/js/muting_ui.js +++ b/static/js/muting_ui.js @@ -45,6 +45,10 @@ exports.handle_updates = function (muted_topics) { exports.rerender(); }; +$(function () { + muting.set_muted_topics(page_params.muted_topics); +}); + return exports; }()); diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 563b2c573a..7de09218bd 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1529,6 +1529,8 @@ def do_events_register(user_profile, user_client, apply_markdown=True, ret['realm_emoji'] = user_profile.realm.get_emoji() if event_types is None or "alert_words" in event_types: ret['alert_words'] = user_alert_words(user_profile) + if event_types is None or "muted_topics" in event_types: + ret['muted_topics'] = ujson.loads(user_profile.muted_topics) # Apply events that came in while we were fetching initial data events = get_user_events(user_profile, queue_id, -1) diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 2d78aa5dc7..c01890aaee 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -708,6 +708,7 @@ def home(request): onboarding_steps = ujson.loads(user_profile.onboarding_steps), staging = settings.STAGING_DEPLOYED or not settings.DEPLOYED, alert_words = register_ret['alert_words'], + muted_topics = register_ret['muted_topics'], show_admin = user_profile.show_admin, notify_for_streams_by_default = notify_for_streams_by_default(user_profile) ))