mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
refactor: Add unread.get_unread_message{_ids}().
This adds two similar functions to simplify
our batch processing of unread messages.
unread.get_unread_messages
unread.get_unread_message_ids
They are used to simplify two functions that loop
over messages. Before this change, the functions
would short circuit the loop to ignore messages
that were already read; now they just use the
helpers before the loop.
This commit is contained in:
@@ -333,8 +333,14 @@ exports.message_unread = function (message) {
|
||||
message.flags.indexOf('read') === -1;
|
||||
};
|
||||
|
||||
exports.id_flagged_as_unread = function (message_id) {
|
||||
return unread_messages.has(message_id);
|
||||
exports.get_unread_message_ids = function (message_ids) {
|
||||
return _.filter(message_ids, unread_messages.has);
|
||||
};
|
||||
|
||||
exports.get_unread_messages = function (message) {
|
||||
return _.filter(message, function (message) {
|
||||
return unread_messages.has(message.id);
|
||||
});
|
||||
};
|
||||
|
||||
exports.update_unread_topics = function (msg, event) {
|
||||
|
||||
Reference in New Issue
Block a user