Fix how we find if streams are muted.

This commit changes stream_data.in_home_view() to
take a stream_id parameter, which will make it more
robust to stream name changes.

This fixes a bug.  Now when an admin renames a stream
you are looking at, it will correctly show itself to
be un-muted. (Even with this fix, though, the stream
appears to be inactive.)

Some callers still do lookups by name, and they will
call name_in_home_view() for now, which we can
hopefully deprecate over time.
This commit is contained in:
Steve Howell
2017-05-13 11:54:53 -07:00
committed by Tim Abbott
parent d3a7aa3a37
commit c125ba1d08
10 changed files with 47 additions and 15 deletions

View File

@@ -15,10 +15,22 @@ function make_tab_data() {
var tabs = [];
var filter = narrow_state.filter();
function filtered_to_non_home_view_stream() {
if (!filter.has_operator('stream')) {
return false;
}
var stream_name = filter.operands('stream')[0];
var stream_id = stream_data.get_stream_id(stream_name);
if (!stream_id) {
return true;
}
return !stream_data.in_home_view(stream_id);
}
// Root breadcrumb item: Either Home or All Messages
if (filter !== undefined &&
((filter.has_operator("stream") &&
!stream_data.in_home_view(filter.operands("stream")[0])) ||
(filtered_to_non_home_view_stream() ||
filter.has_operand("in", "all"))) {
tabs.push(make_tab("All Messages", "#narrow/in/all", undefined, "root"));
} else if (page_params.narrow !== undefined) {