mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 01:47:41 +00:00
Avoid blueslip error for empty streams.
We simplify the code for deciding whether we show a subscribe button or not, and in doing so avoid a blueslip error where we were passing `undefined` into `get_sub()`.
This commit is contained in:
@@ -946,11 +946,23 @@ function pick_empty_narrow_banner() {
|
|||||||
} else if (first_operator === "stream" && !stream_data.is_subscribed(first_operand)) {
|
} else if (first_operator === "stream" && !stream_data.is_subscribed(first_operand)) {
|
||||||
// You are narrowed to a stream which does not exist or is a private stream
|
// You are narrowed to a stream which does not exist or is a private stream
|
||||||
// in which you were never subscribed.
|
// in which you were never subscribed.
|
||||||
const stream_sub = stream_data.get_sub(narrow_state.stream());
|
|
||||||
if (!stream_sub || !stream_sub.should_display_subscription_button) {
|
function should_display_subscription_button() {
|
||||||
return $("#nonsubbed_private_nonexistent_stream_narrow_message");
|
const stream_name = narrow_state.stream();
|
||||||
|
|
||||||
|
if (!stream_name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream_sub = stream_data.get_sub(first_operand);
|
||||||
|
return stream_sub && stream_sub.should_display_subscription_button;
|
||||||
}
|
}
|
||||||
return $("#nonsubbed_stream_narrow_message");
|
|
||||||
|
if (should_display_subscription_button()) {
|
||||||
|
return $("#nonsubbed_stream_narrow_message");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $("#nonsubbed_private_nonexistent_stream_narrow_message");
|
||||||
} else if (first_operator === "search") {
|
} else if (first_operator === "search") {
|
||||||
// You are narrowed to empty search results.
|
// You are narrowed to empty search results.
|
||||||
show_search_query();
|
show_search_query();
|
||||||
|
|||||||
Reference in New Issue
Block a user