narrow_banner: Differentiate between unknown channel and new topic.

This commit is contained in:
evykassirer 2024-10-12 23:21:52 -07:00 committed by Tim Abbott
parent 2c9d4eaeee
commit 55f97c6559
2 changed files with 28 additions and 1 deletions

View File

@ -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;
}

View File

@ -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});