From 6ca145b2ede13dcb51a51e76eeabd9d1aaf24b8e Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 10 May 2018 11:11:53 +0000 Subject: [PATCH] Add unread.get_all_msg_ids(). --- frontend_tests/node_tests/unread.js | 7 +++++++ static/js/unread.js | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/frontend_tests/node_tests/unread.js b/frontend_tests/node_tests/unread.js index 6eb1a4c815..b451d12ff3 100644 --- a/frontend_tests/node_tests/unread.js +++ b/frontend_tests/node_tests/unread.js @@ -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() { diff --git a/static/js/unread.js b/static/js/unread.js index ebbdc9f8b4..cc4af372ab 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -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