diff --git a/frontend_tests/node_tests/narrow_unread.js b/frontend_tests/node_tests/narrow_unread.js index 537a6889be..b08bf6490e 100644 --- a/frontend_tests/node_tests/narrow_unread.js +++ b/frontend_tests/node_tests/narrow_unread.js @@ -71,7 +71,7 @@ function candidate_ids() { assert.equal(unread_ids, undefined); terms = [ - {operator: 'sender', operand: 'me@example.com'}, + {operator: 'bogus_operator', operand: 'me@example.com'}, ]; set_filter(terms); unread_ids = candidate_ids(); @@ -129,6 +129,17 @@ function candidate_ids() { unread_ids = candidate_ids(); assert.deepEqual(unread_ids, [stream_msg.id]); + terms = [ + {operator: 'sender', operand: 'me@example.com'}, + ]; + set_filter(terms); + // note that our candidate ids are just "all" ids now + unread_ids = candidate_ids(); + assert.deepEqual(unread_ids, [stream_msg.id]); + + // this actually does filtering + assert_unread_info({flavor: 'not_found'}); + terms = [ {operator: 'pm-with', operand: 'alice@example.com'}, ]; diff --git a/static/js/narrow_state.js b/static/js/narrow_state.js index 37f4f7b5d8..fc245fecdc 100644 --- a/static/js/narrow_state.js +++ b/static/js/narrow_state.js @@ -256,6 +256,11 @@ exports._possible_unread_message_ids = function () { return unread.get_msg_ids_for_starred(); } + if (current_filter.can_bucket_by('sender')) { + // TODO: see #9352 to make this more efficient + return unread.get_all_msg_ids(); + } + return; };