mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
We now use a client-side message id to track the state of our sent messages. This sets up future commits to start tracking state earlier in the message's life cycle. It also avoids ugly reify logic where we capture an event to update our data structure to key on the server's message id instead of the local id. That eliminates the node test as well. Another node test gets deleted here, just because it's not worth the trouble with upcoming refactorings.
39 lines
965 B
JavaScript
39 lines
965 B
JavaScript
var message_util = (function () {
|
|
|
|
var exports = {};
|
|
|
|
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();
|
|
};
|
|
|
|
exports.add_messages = function add_messages(messages, msg_list, opts) {
|
|
if (!messages) {
|
|
return;
|
|
}
|
|
|
|
opts = _.extend({messages_are_new: false, delay_render: false}, opts);
|
|
|
|
loading.destroy_indicator($('#page_loading_indicator'));
|
|
$('#first_run_message').remove();
|
|
|
|
msg_list.add_messages(messages, opts);
|
|
|
|
if (msg_list === home_msg_list && opts.messages_are_new) {
|
|
_.each(messages, function (message) {
|
|
if (message.local_id === undefined) {
|
|
sent_messages.report_as_received(message.client_message_id);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
if (typeof module !== 'undefined') {
|
|
module.exports = message_util;
|
|
}
|