Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

recent_view_ui: Avoid non-contiguous rows in recent view.

Aman Agrawal2348d6f1f91c
diff --git a/web/src/message_fetch.js b/web/src/message_fetch.js
index d8e0a513fb5..c941104a555 100644
--- a/web/src/message_fetch.js
+++ b/web/src/message_fetch.js
@@ -61,9 +61,11 @@ function process_result(data, opts) {
}
}
- if (messages.length > 0 && opts.msg_list === message_lists.home) {
- // We keep track of how far back we've fetched messages for, for messaging in
- // the recent view. This assumes `data.messages` is already sorted.
+ if (messages.length > 0 && (opts.msg_list === message_lists.home || opts.is_recent_view_data)) {
+ recent_view_ui.process_messages(messages);
+
+ // Update the recent view UI's understanding of which messages
+ // we have available for the recent view.
const oldest_timestamp = all_messages_data.first().timestamp;
recent_view_ui.set_oldest_message_date(
oldest_timestamp,
@@ -73,7 +75,6 @@ function process_result(data, opts) {
}
huddle_data.process_loaded_messages(messages);
- recent_view_ui.process_messages(messages);
stream_list.update_streams_sidebar();
stream_list.maybe_scroll_narrow_into_view();
@@ -591,6 +592,7 @@ export function initialize(home_view_loaded) {
num_before: consts.recent_view_initial_fetch_size,
num_after: 0,
msg_list_data: recent_view_message_list_data,
+ is_recent_view_data: true,
cont: recent_view_ui.hide_loading_indicator,
});
}
diff --git a/web/src/recent_view_ui.js b/web/src/recent_view_ui.js
index fb0d5e2ddc0..372532d69c1 100644
--- a/web/src/recent_view_ui.js
+++ b/web/src/recent_view_ui.js
@@ -370,10 +370,15 @@ export function hide_loading_indicator() {
}
export function process_messages(messages) {
- // While this is inexpensive and handles all the cases itself,
- // the UX can be bad if user wants to scroll down the list as
- // the UI will be returned to the beginning of the list on every
- // update.
+ // This code path processes messages from 3 sources:
+
+ // 1. Newly sent messages from the server_events system. This is safe to
+ // process because we always will have the latest previously sent messages.
+ // 2. Messages in all_messages_data, the main cache of contiguous
+ // message history that the client maintains.
+ // 3. Latest messages fetched specifically for Recent view when
+ // the browser first loads. We will be able to remove this once
+ // all_messages_data is fetched in a better order.
let conversation_data_updated = false;
if (messages.length > 0) {
for (const msg of messages) {