Files
zulip/static/js/message_util.js
Aman Agrawal 5443b2f635 recent_senders: Update data structures for stream/topic edits.
* Remove old topic and reprocess both old and new topic to ensure
that we are correctly storing the last_msg_id of users in the
topic. Also, Handle topic's stream (& topic) edit updates.
* Add function to get all messages in a topic in message_utils.js.
* Send topic edit event to recent_senders.
* Add func get sorted list of recent_senders to topic.
The function will be useful to handle topic edits in Recent Topic UI.
2020-05-12 00:15:26 -07:00

40 lines
1.3 KiB
JavaScript

exports.do_unread_count_updates = function do_unread_count_updates(messages) {
unread.process_loaded_messages(messages);
unread_ui.update_unread_counts();
resize.resize_page_components();
};
function add_messages(messages, msg_list, opts) {
if (!messages) {
return;
}
loading.destroy_indicator($('#page_loading_indicator'));
$('#first_run_message').remove();
const render_info = msg_list.add_messages(messages, opts);
return render_info;
}
exports.add_old_messages = function (messages, msg_list) {
return add_messages(messages, msg_list, {messages_are_new: false});
};
exports.add_new_messages = function (messages, msg_list) {
return add_messages(messages, msg_list, {messages_are_new: true});
};
exports.get_messages_in_topic = function (stream_id, topic) {
// This function is very expensive since it searches
// all the messages. Please only use it in case of
// very rare events like topic edits. Its primary
// use case is the new experimental Recent Topics UI.
return message_list.all.all_messages().filter(x => {
return x.type === 'stream' &&
x.stream_id === stream_id &&
x.topic.toLowerCase() === topic.toLowerCase();
});
};
window.message_util = exports;