From 25eeaaf1e56bb5ba0605207ce7c138705ed2ee99 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 4 Dec 2015 16:21:42 +0000 Subject: [PATCH] Use UnreadStatus to determine whether an event affects a room;s unread status. Unify rooms going bold with their sort order and don't go bold for m.notify. --- src/components/structures/RoomSubList.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomSubList.js b/src/components/structures/RoomSubList.js index 8623787f..9961ddb7 100644 --- a/src/components/structures/RoomSubList.js +++ b/src/components/structures/RoomSubList.js @@ -20,6 +20,7 @@ var React = require('react'); var DropTarget = require('react-dnd').DropTarget; var sdk = require('matrix-react-sdk') var dis = require('matrix-react-sdk/lib/dispatcher'); +var UnreadStatus = require('matrix-react-sdk/lib/UnreadStatus'); // turn this on for drop & drag console debugging galore var debug = false; @@ -88,10 +89,20 @@ var RoomSubList = React.createClass({ }, tsOfNewestEvent: function(room) { - if (room.timeline.length) { - return room.timeline[room.timeline.length - 1].getTs(); + for (var i = room.timeline.length - 1; i >= 0; --i) { + var ev = room.timeline[i]; + // logic copied from RoomList.js for when we do/don't highlight + if (UnreadStatus.eventTriggersUnreadCount(ev)) { + return ev.getTs(); + } } - else { + + // we might only have events that don't trigger the unread indicator, + // in which case use the oldest event even if normally it wouldn't count. + // This is better than just assuming the last event was forever ago. + if (room.timeline.length) { + return room.timeline[0].getTs(); + } else { return Number.MAX_SAFE_INTEGER; } },