Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

narrow_banner: Differentiate between unknown channel and new topic.

evykassirer55f97c6559dc
diff --git a/web/src/narrow_banner.ts b/web/src/narrow_banner.ts
index 52dc26551a0..c0576510377 100644
--- a/web/src/narrow_banner.ts
+++ b/web/src/narrow_banner.ts
@@ -192,7 +192,21 @@ export function pick_empty_narrow_banner(): NarrowBannerData {
return SPECTATOR_STREAM_NARROW_BANNER;
}
- // A stream > topic that doesn't exist yet.
+ if (streams.length === 1) {
+ const stream_sub = stream_data.get_sub_by_id_string(
+ util.the(current_filter.operands("channel")),
+ );
+ if (!stream_sub) {
+ return {
+ title: $t({
+ defaultMessage:
+ "This channel doesn't exist, or you are not allowed to view it.",
+ }),
+ };
+ }
+ }
+
+ // A valid stream, but a topic that doesn't exist yet.
if (num_terms === 2 && streams.length === 1 && topics.length === 1) {
return default_banner;
}
diff --git a/web/tests/message_view.test.js b/web/tests/message_view.test.js
index 767cac8c7b1..1d72c637c79 100644
--- a/web/tests/message_view.test.js
+++ b/web/tests/message_view.test.js
@@ -258,6 +258,19 @@ run_test("show_empty_narrow_message", ({mock_template, override}) => {
),
);
+ set_filter([
+ ["stream", "999"],
+ ["topic", "foo"],
+ ["near", "99"],
+ ]);
+ narrow_banner.show_empty_narrow_message();
+ assert.equal(
+ $(".empty_feed_notice_main").html(),
+ empty_narrow_html(
+ "translated: This channel doesn't exist, or you are not allowed to view it.",
+ ),
+ );
+
// for non-subbed public stream
const rome_id = 99;
stream_data.add_sub({name: "ROME", stream_id: rome_id});