mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +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)) {
|
||||
// You are narrowed to a stream which does not exist or is a private stream
|
||||
// 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) {
|
||||
return $("#nonsubbed_private_nonexistent_stream_narrow_message");
|
||||
|
||||
function should_display_subscription_button() {
|
||||
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") {
|
||||
// You are narrowed to empty search results.
|
||||
show_search_query();
|
||||
|
||||
Reference in New Issue
Block a user