From c5904499db2d6a47da9e48eea743b26f38b64003 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 9 Mar 2018 17:59:13 -0800 Subject: [PATCH] stream_data: Move calls to update_calculated_fields to events layer. This migrates what were effectively data update functions to be called from the main stream_events handlers, instead of being called from the view-update code in subs.js. --- static/js/stream_events.js | 3 ++- static/js/subs.js | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/static/js/stream_events.js b/static/js/stream_events.js index 5194888761..213f4ccb58 100644 --- a/static/js/stream_events.js +++ b/static/js/stream_events.js @@ -105,6 +105,7 @@ exports.mark_subscribed = function (sub, subscribers, color) { if (subscribers) { stream_data.set_subscribers(sub, subscribers); } + stream_data.update_calculated_fields(sub); if (overlays.streams_open()) { subs.update_settings_for_subscribed(sub); @@ -128,7 +129,7 @@ exports.mark_unsubscribed = function (sub) { return; } else if (sub.subscribed) { stream_data.unsubscribe_myself(sub); - + stream_data.update_calculated_fields(sub); if (overlays.streams_open()) { subs.update_settings_for_unsubscribed(sub); } diff --git a/static/js/subs.js b/static/js/subs.js index ec570fc48d..6396d724c0 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -179,7 +179,6 @@ function add_email_hint(row, email_address_hint_content) { // this request. These should be appended to the top of the list so // they are more visible. function add_sub_to_table(sub) { - stream_data.update_calculated_fields(sub); var html = templates.render('subscription', sub); var settings_html = templates.render('subscription_settings', sub); if (stream_create.get_name() === sub.name) { @@ -248,7 +247,6 @@ exports.update_settings_for_unsubscribed = function (sub) { // If user unsubscribed from private stream then user can not subscribe to // stream without invitation. So hide subscribe button. - stream_data.update_calculated_fields(sub); if (!sub.should_display_subscription_button) { settings_button.hide(); }