From edae66fd3a96d1a77cd68b13e5584c44cb57a570 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 26 Jun 2017 14:28:56 +0100 Subject: [PATCH] fix one major cause of stuck unread notifications --- src/Unread.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Unread.js b/src/Unread.js index 67166dc24f..8a70291cf2 100644 --- a/src/Unread.js +++ b/src/Unread.js @@ -37,7 +37,26 @@ module.exports = { }, 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 // 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