message_fetch: Avoid double-fetching muted topic messages.

Previously, when backfilling in a stream narrow (the main situation
where _items != _all_items), we would double-fetch any muted messages
older than the oldest message not hidden due to topic or user muting.

We change the all_messages fetch to use this function even though it
doesn't matter, just for clarity about the intent.

Since this bug could have prevented making progress fixes a
theoretical bug that could result in the client trying to fetch
messages for a given narrow indefinitely.
This commit is contained in:
Tim Abbott
2023-05-01 18:26:00 -07:00
parent 1ce17f7403
commit 4e6b27b25f

View File

@@ -303,7 +303,9 @@ export function load_messages_for_narrow(opts) {
export function get_backfill_anchor(msg_list) {
const oldest_msg =
msg_list === message_lists.home ? all_messages_data.first() : msg_list.first();
msg_list === message_lists.home
? all_messages_data.first_including_muted()
: msg_list.data.first_including_muted();
if (oldest_msg) {
return oldest_msg.id;
@@ -315,7 +317,10 @@ export function get_backfill_anchor(msg_list) {
}
export function get_frontfill_anchor(msg_list) {
const last_msg = msg_list === message_lists.home ? all_messages_data.last() : msg_list.last();
const last_msg =
msg_list === message_lists.home
? all_messages_data.last_including_muted()
: msg_list.data.last_including_muted();
if (last_msg) {
return last_msg.id;