Merge pull request #1147 from matrix-org/matthew/stuck-unread

fix one major cause of stuck unread notifications
This commit is contained in:
David Baker 2017-06-26 14:57:25 +01:00 committed by GitHub
commit f9b37208a3

View file

@ -37,7 +37,26 @@ module.exports = {
}, },
doesRoomHaveUnreadMessages: function(room) { doesRoomHaveUnreadMessages: function(room) {
var readUpToId = room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId); var myUserId = MatrixClientPeg.get().credentials.userId;
// get the most recent read receipt sent by our account.
// N.B. this is NOT a read marker (RM, aka "read up to marker"),
// despite the name of the method :((
var readUpToId = room.getEventReadUpTo(myUserId);
// as we don't send RRs for our own messages, make sure we special case that
// if *we* sent the last message into the room, we consider it not unread!
// Should fix: https://github.com/vector-im/riot-web/issues/3263
// https://github.com/vector-im/riot-web/issues/2427
// ...and possibly some of the others at
// https://github.com/vector-im/riot-web/issues/3363
if (room.timeline.length &&
room.timeline[room.timeline.length - 1].sender &&
room.timeline[room.timeline.length - 1].sender.userId === myUserId)
{
return false;
}
// this just looks at whatever history we have, which if we've only just started // this just looks at whatever history we have, which if we've only just started
// up probably won't be very much, so if the last couple of events are ones that // up probably won't be very much, so if the last couple of events are ones that
// don't count, we don't know if there are any events that do count between where // don't count, we don't know if there are any events that do count between where