message_list: Extract visibly_empty helper method.

This function will allow us to adjust the codebase to write what it
means semantically -- whether a check is for the message list being
visibly empty, or completely empty.

In this commit, we leave the .empty() method incorrect, because
several other adjustments need to be made atomically with fixing it.
This commit is contained in:
Tim Abbott
2023-05-01 19:04:46 -07:00
parent 8f1c3a0fa1
commit 804f473214
13 changed files with 41 additions and 30 deletions

View File

@@ -116,14 +116,14 @@ export class MessageList {
render_info = this.append_to_view(bottom_messages, opts);
}
if (this.narrowed && !this.empty()) {
if (this.narrowed && !this.visibly_empty()) {
// If adding some new messages to the message tables caused
// our current narrow to no longer be empty, hide the empty
// feed placeholder text.
narrow_banner.hide_empty_narrow_message();
}
if (this.narrowed && !this.empty() && this.selected_id() === -1) {
if (this.narrowed && !this.visibly_empty() && this.selected_id() === -1) {
// The message list was previously empty, but now isn't
// due to adding these messages, and we need to select a
// message. Regardless of whether the messages are new or
@@ -147,6 +147,10 @@ export class MessageList {
return this.data.empty();
}
visibly_empty() {
return this.data.visibly_empty();
}
first() {
return this.data.first();
}
@@ -437,7 +441,7 @@ export class MessageList {
this.view.update_render_window(this.selected_idx(), false);
if (this.narrowed) {
if (this.empty()) {
if (this.visibly_empty()) {
narrow_banner.show_empty_narrow_message();
} else {
narrow_banner.hide_empty_narrow_message();