Add unread.get_all_msg_ids().

This commit is contained in:
Steve Howell 2018-05-10 11:11:53 +00:00 committed by Tim Abbott
parent 073ecaac66
commit 6ca145b2ed
2 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,7 @@ var zero_counts = {
unread.process_loaded_messages([message, other_message]);
assert.deepEqual(unread.get_all_msg_ids(), [15, 16]);
assert.deepEqual(unread.get_unread_message_ids([15, 16]), [15, 16]);
assert.deepEqual(
unread.get_unread_messages([message, other_message]),
@ -235,6 +236,9 @@ stream_data.get_stream_id = function () {
assert.equal(unread.num_unread_for_stream(stream_id), 0);
assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), []);
// we still find the message id here (muting is ignored)
assert.deepEqual(unread.get_all_msg_ids(), [message.id]);
assert.equal(unread.num_unread_for_stream(unknown_stream_id), 0);
}());
@ -445,6 +449,7 @@ stream_data.get_stream_id = function () {
assert.deepEqual(unread.get_msg_ids_for_person(alice.user_id), [message.id]);
assert.deepEqual(unread.get_msg_ids_for_person(bob.user_id), []);
assert.deepEqual(unread.get_msg_ids_for_private(), [message.id]);
assert.deepEqual(unread.get_all_msg_ids(), [message.id]);
}());
@ -474,6 +479,7 @@ stream_data.get_stream_id = function () {
counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 1);
assert.deepEqual(unread.get_msg_ids_for_mentions(), [message.id]);
assert.deepEqual(unread.get_all_msg_ids(), [message.id]);
unread.mark_as_read(message.id);
counts = unread.get_counts();
assert.equal(counts.mentioned_message_count, 0);
@ -573,6 +579,7 @@ stream_data.get_stream_id = function () {
msg_ids = unread.get_msg_ids_for_stream(stream_id);
assert.deepEqual(msg_ids, []);
assert.deepEqual(unread.get_all_msg_ids(), []);
}());
(function test_errors() {

View File

@ -539,6 +539,12 @@ exports.get_msg_ids_for_mentions = function () {
return util.sorted_ids(ids);
};
exports.get_all_msg_ids = function () {
var ids = unread_messages.members();
return util.sorted_ids(ids);
};
exports.get_msg_ids_for_starred = function () {
// This is here for API consistency sake--we never
// have unread starred messages. (Some day we may ironically