Use throttle, not debounce, to "read" messages.

We were queuing up individual messages to be flagged as
read on the server before this change, and we used debounce
to avoid sending individual POSTs, but this created delays
that were ripe for race conditions.

Now we batch them in the caller and use throttle instead.
This now prevents us from slamming the server with lots of
individual requests, without as many opportunities for races.

(Note that we still have some possibility of race conditions,
but they should be rare now, and other commits will address
some of the other contributors to read/unread glitches.)
This commit is contained in:
Steve Howell
2017-12-21 11:51:52 -05:00
committed by showell
parent 204949396c
commit 58ec5f9695
2 changed files with 5 additions and 4 deletions

View File

@@ -65,12 +65,13 @@ exports.mark_messages_as_read = function (messages, options) {
return;
}
message_flags.send_read(messages);
_.each(messages, function (message) {
if (current_msg_list === message_list.narrowed) {
unread.messages_read_in_narrow = true;
}
message_flags.send_read(message);
unread.mark_as_read(message.id);
process_newly_read_message(message, options);
});