mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
This is mostly straightforward moving of code out of compose.js.
The code that was moved currently supports sending time
reports for sent messages, but we intend to grow out the new
module to track more state about sent messages.
The following function names in this commit are new, but their
code was basically pulled over verbatim:
process_success (was process_send_time)
set_timer_for_restarting_event_loop
clear
initialize
All the code in the new module is covered by previous tests that
had been written for compose.js. This commit only modifies
a few things to keep those tests.
The new module has 100% node coverage, so we updated `enforce_fully_covered`.
39 lines
947 B
JavaScript
39 lines
947 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);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
if (typeof module !== 'undefined') {
|
|
module.exports = message_util;
|
|
}
|