From 6b48fb3c08ed6fe34597fec8045fefa87d469560 Mon Sep 17 00:00:00 2001 From: Suyash Vardhan Mathur Date: Thu, 13 Aug 2020 18:06:41 +0530 Subject: [PATCH] streams: Fix live update of stream name when renamed. Currently, the Stream Name change isn't reflected in the streams sidebar when a stream is renamed if the order of streams in the sidebar remains unchanged, because the optimization to avoid rerendering when nothing changes about the order prevents the rerendering code from running. We fix by this adding a flag in build_stream_list and update_streams_sidebar functions to force a rerender, and pass that when a stream is renamed. Fixes #16026. --- static/js/stream_list.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/static/js/stream_list.js b/static/js/stream_list.js index f68fd83ff6..3086041059 100644 --- a/static/js/stream_list.js +++ b/static/js/stream_list.js @@ -84,7 +84,7 @@ exports.create_initial_sidebar_rows = function () { } }; -exports.build_stream_list = function () { +exports.build_stream_list = function (force_rerender) { // This function assumes we have already created the individual // sidebar rows. Our job here is to build the bigger widget, // which largely is a matter of arranging the individual rows in @@ -98,7 +98,7 @@ exports.build_stream_list = function () { // we get three lists of streams (pinned/normal/dormant). const stream_groups = stream_sort.sort_groups(streams, get_search_term()); - if (stream_groups.same_as_before) { + if (stream_groups.same_as_before && !force_rerender) { return; } @@ -307,9 +307,9 @@ function set_stream_unread_count(stream_id, count) { exports.update_count_in_dom(unread_count_elem, count); } -exports.update_streams_sidebar = function () { +exports.update_streams_sidebar = function (force_rerender) { const finish = blueslip.start_timing("build_stream_list"); - exports.build_stream_list(); + exports.build_stream_list(force_rerender); finish(); exports.stream_cursor.redraw(); @@ -332,7 +332,7 @@ exports.update_dom_with_unread_counts = function (counts) { exports.rename_stream = function (sub) { // The sub object is expected to already have the updated name build_stream_sidebar_row(sub); - exports.update_streams_sidebar(); // big hammer + exports.update_streams_sidebar(true); // big hammer }; exports.refresh_pinned_or_unpinned_stream = function (sub) {