mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
Fix test for adding to top or bottom of zhome/zfilt
It's possible for selected_message_id to not exist in zhome. For instance, when you open the page to a narrowed URL, there is a race between loading the narrowed messages and loading all your messages. If the narrowed message request completes first, it will update selected_message_id to your initial_pointer if the latter happens to be among the narrowed messages. Even if it is not, you can select a message by clicking on it before the zhome request finishes. Then the old code would never add that selected_message_id to the zhome table, so it wouldn't show up in the Home view or if you re-narrowed. I'm pretty sure there are still cases where the selected_message_id might be outside the range of messages in zhome, in which case adding to zhome might put old messages at the bottom. I observed this twice on staging but was unable to reproduce it consistently. (imported from commit 162feff3090f8806cc67140db0cfabb6e965aece)
This commit is contained in:
@@ -478,7 +478,7 @@ function add_messages(messages, add_to_home) {
|
||||
return (elem.id < selected_message_id && ! message_in_table.zhome[elem.id]);
|
||||
});
|
||||
var bottom_messages_home = $.grep(messages, function (elem, idx) {
|
||||
return (elem.id > selected_message_id && ! message_in_table.zhome[elem.id]);
|
||||
return (elem.id >= selected_message_id && ! message_in_table.zhome[elem.id]);
|
||||
});
|
||||
message_array = top_messages_home.concat(message_array).concat(bottom_messages_home);
|
||||
add_to_table(top_messages_home, 'zhome', function () { return true; }, "top", true);
|
||||
@@ -493,7 +493,7 @@ function add_messages(messages, add_to_home) {
|
||||
return (elem.id < selected_message_id && ! message_in_table.zfilt[elem.id]);
|
||||
});
|
||||
var bottom_messages_narrow = $.grep(messages, function (elem, idx) {
|
||||
return (elem.id > selected_message_id && ! message_in_table.zfilt[elem.id]);
|
||||
return (elem.id >= selected_message_id && ! message_in_table.zfilt[elem.id]);
|
||||
});
|
||||
add_to_table(top_messages_narrow, 'zfilt', narrow.predicate(), "top", narrow.allow_collapse());
|
||||
add_to_table(bottom_messages_narrow, 'zfilt', narrow.predicate(), "bottom", narrow.allow_collapse());
|
||||
|
||||
Reference in New Issue
Block a user