search: Don't mark messages as read in search narrow.

Don't mark unread messages as read while searching.
This behavior will be extended to other narrows later.

Fixes: #12556.
This commit is contained in:
Mohit Gupta
2019-07-10 05:33:41 +05:30
committed by Tim Abbott
parent bd52ec9f95
commit 6ec40cf9a0
15 changed files with 66 additions and 10 deletions

View File

@@ -82,6 +82,9 @@ function stub_selected_message(msg) {
selected_message: function () {
return msg;
},
can_mark_messages_read: function () {
return true;
},
});
}

View File

@@ -68,6 +68,7 @@ run_test('basics', () => {
assert(!filter.has_operand('stream', 'nada'));
assert(!filter.is_search());
assert(filter.can_mark_messages_read());
assert(filter.can_apply_locally());
operators = [
@@ -78,6 +79,7 @@ run_test('basics', () => {
filter = new Filter(operators);
assert(filter.is_search());
assert(!filter.can_mark_messages_read());
assert(!filter.can_apply_locally());
assert(!filter.is_exactly('stream'));

View File

@@ -527,8 +527,11 @@ run_test('unread_ops', () => {
// Make us not be in a narrow (somewhat hackily).
message_list.narrowed = undefined;
// Set current_message_list containing messages that
// can be marked read
set_global('current_msg_list', {
all_messages: () => test_messages,
can_mark_messages_read: () => true,
});
// Ignore these interactions for now:
@@ -544,6 +547,12 @@ run_test('unread_ops', () => {
channel_post_opts = opts;
};
// First, test for a message list that cannot read messages
current_msg_list.can_mark_messages_read = () => false;
unread_ops.process_visible();
assert.deepEqual(channel_post_opts, undefined);
current_msg_list.can_mark_messages_read = () => true;
// Do the main thing we're testing!
unread_ops.process_visible();
@@ -556,6 +565,7 @@ run_test('unread_ops', () => {
data: { messages: '[50]', op: 'add', flag: 'read' },
success: channel_post_opts.success,
});
});
/*

View File

@@ -13,7 +13,10 @@ run_test('starred', () => {
const message = {
id: 50,
};
set_global('current_msg_list', {
all_messages: () => [message],
is_search: () => false,
});
var ui_updated;
ui.update_starred_view = () => {

View File

@@ -37,7 +37,7 @@ run_test('basics', () => {
});
assert.equal(mld.is_search(), false);
assert(mld.can_mark_messages_read());
mld.add_anywhere(make_msgs([35, 25, 15, 45]));
assert_contents(mld, [15, 25, 35, 45]);