mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 09:58:06 +00:00
recent-conversations: Update logic for processing messages.
As of 550a32b, when private messages were added to recent
conversations, `recent_topics_data.process_message` will
always return true.
Updates `recent_topics_data.process_message` for no return
value. Also, removes the `topic_data_changed` logic from
`recent_topics_ui.process_messages` and instead checks for
messages to process before updating the data and calling the
rerender.
`recent_topics_ui.complete_rerender` first checks for whether
the recent conversations view is visible before rerendering.
This commit is contained in:
committed by
Tim Abbott
parent
5c833f0423
commit
79c0d7fbab
@@ -4,9 +4,6 @@ import {get_key_from_message} from "./recent_topics_util";
|
||||
export const topics = new Map(); // Key is stream-id:topic.
|
||||
|
||||
export function process_message(msg) {
|
||||
// This function returns if topic_data
|
||||
// has changed or not.
|
||||
|
||||
// Initialize topic and pm data
|
||||
// Key for private message is the user id's
|
||||
// to whom the message is begin sent.
|
||||
@@ -34,7 +31,6 @@ export function process_message(msg) {
|
||||
// message fetched in the topic. Ideally we would want this to be attached
|
||||
// to topic info fetched from backend, which is currently not a thing.
|
||||
topic_data.participated = is_ours || topic_data.participated;
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_sorted_topics() {
|
||||
|
||||
@@ -298,17 +298,10 @@ export function process_messages(messages) {
|
||||
// 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.
|
||||
//
|
||||
// Only rerender if topic_data actually
|
||||
// changed.
|
||||
let topic_data_changed = false;
|
||||
for (const msg of messages) {
|
||||
if (process_message(msg)) {
|
||||
topic_data_changed = true;
|
||||
if (messages.length > 0) {
|
||||
for (const msg of messages) {
|
||||
process_message(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (topic_data_changed) {
|
||||
complete_rerender();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user