message_list: Fix just_unsubscribed for empty views.

This fixes a bug where wrong bookend is shown in empty views in
the next commit.
This commit is contained in:
Aman Agrawal
2025-03-25 19:13:30 +05:30
committed by Tim Abbott
parent a9fa5b66a2
commit afbc6f2510
2 changed files with 24 additions and 1 deletions

View File

@@ -469,7 +469,7 @@ export class MessageList {
const is_web_public = sub?.is_web_public;
if (sub === undefined || sub.is_archived) {
deactivated = true;
} else if (!subscribed && !this.last_message_historical) {
} else if (!subscribed && !this.last_message_historical && !this.empty()) {
just_unsubscribed = true;
}

View File

@@ -387,6 +387,29 @@ run_test("bookend", ({override}) => {
list.last_message_historical = false;
is_subscribed = false;
{
const stub = make_stub();
list.view.render_trailing_bookend = stub.f;
list.update_trailing_bookend();
assert.equal(stub.num_calls, 1);
const bookend = stub.get_args(
"stream_id",
"stream_name",
"subscribed",
"deactivated",
"just_unsubscribed",
);
assert.equal(bookend.stream_id, 5);
assert.equal(bookend.stream_name, "IceCream");
assert.equal(bookend.subscribed, false);
assert.equal(bookend.deactivated, false);
assert.equal(bookend.just_unsubscribed, false);
}
list.last_message_historical = false;
is_subscribed = false;
list.empty = () => false;
{
const stub = make_stub();
list.view.render_trailing_bookend = stub.f;