mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
navbar: Switch make_tab_bar conditionals to using filter/sub values.
Previously, this function relied on the return value of `filter.get_icon()` which made it brittle. Directly using the properties of the filter and sub object makes this more explicit about the intentions and robust.
This commit is contained in:
parent
7ea60ea1ab
commit
ab2e7e097a
@ -25,13 +25,16 @@ function make_tab_data(filter) {
|
||||
}
|
||||
tab_data.title = filter.get_title();
|
||||
tab_data.icon = filter.get_icon();
|
||||
if (tab_data.icon === 'question-circle-o') {
|
||||
if (filter.has_operator('stream') && !filter._sub) {
|
||||
tab_data.sub_count = '0';
|
||||
tab_data.formatted_sub_count = '0';
|
||||
tab_data.rendered_narrow_description = i18n.t("This stream does not exist or is private.");
|
||||
return tab_data;
|
||||
}
|
||||
if (['hashtag', 'lock', 'globe'].includes(tab_data.icon)) {
|
||||
if (filter._sub) {
|
||||
// We can now be certain that the narrow
|
||||
// involves a stream which exists and
|
||||
// the current user can access.
|
||||
const stream = filter.operands("stream")[0];
|
||||
// We can rely on current_stream because if the stream doesn't
|
||||
// exist then the "question-circle-o" case would case early exit.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user