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

@@ -180,11 +180,21 @@ exports.get_color = function (stream_name) {
return sub.color;
};
exports.in_home_view = function (stream_name) {
exports.in_home_view = function (stream_id) {
var sub = exports.get_sub_by_id(stream_id);
return sub !== undefined && sub.in_home_view;
};
exports.name_in_home_view = function (stream_name) {
var sub = exports.get_sub(stream_name);
return sub !== undefined && sub.in_home_view;
};
exports.notifications_in_home_view = function () {
// TODO: add page_params.notifications_stream_id
return exports.name_in_home_view(page_params.notifications_stream);
};
exports.is_subscribed = function (stream_name) {
var sub = exports.get_sub(stream_name);
return sub !== undefined && sub.subscribed;
@@ -454,9 +464,12 @@ exports.get_newbie_stream = function () {
if (exports.is_subscribed("new members")) {
return "new members";
} else if (exports.in_home_view(page_params.notifications_stream)) {
}
if (exports.notifications_in_home_view()) {
return page_params.notifications_stream;
}
return undefined;
};