Extract message.set_read_flag().

This code adds 'read' to message.flags and sets message.unread
to false.

It's not clear that the boolean message.unread is used in any
meaningful way, but we set it to false to avoid confusion.  The
bankruptcy code was not doing this before.

Another quirk that existed before was that you could get two
'read' flags in a message when you declared bankruptcy.  It's
also plausible that this could happen if you marked a message
as read via two different ways.  It probably did not cause
user-facing bugs, but it would be confusing for troubleshooting.

Fixes #5032.
This commit is contained in:
Steve Howell
2017-08-04 07:42:38 -04:00
committed by Tim Abbott
parent d5681556d5
commit ff54d52589
3 changed files with 33 additions and 5 deletions

View File

@@ -4,8 +4,7 @@ var exports = {};
exports.mark_all_as_read = function mark_all_as_read(cont) {
_.each(message_list.all.all_messages(), function (msg) {
msg.flags = msg.flags || [];
msg.flags.push('read');
unread.set_read_flag(msg);
});
unread.declare_bankruptcy();
unread_ui.update_unread_counts();
@@ -24,9 +23,7 @@ function process_newly_read_message(message, options) {
// This code gets called when a message becomes newly read, whether
// due to local things like advancing the pointer, or due to us
// getting notified by the server that a message has been read.
message.flags = message.flags || [];
message.flags.push('read');
message.unread = false;
unread.set_read_flag(message);
home_msg_list.show_message_as_read(message, options);
message_list.all.show_message_as_read(message, options);