Merge pull request #3536 from vector-im/luke/fix-people-unstable-ordering

Do not assume getTs will return comparable integer
This commit is contained in:
David Baker 2017-03-29 14:40:51 +01:00 committed by GitHub
commit e248a7f029
1 changed files with 5 additions and 4 deletions

View File

@ -156,9 +156,10 @@ var RoomSubList = React.createClass({
tsOfNewestEvent: function(room) { tsOfNewestEvent: function(room) {
for (var i = room.timeline.length - 1; i >= 0; --i) { for (var i = room.timeline.length - 1; i >= 0; --i) {
var ev = room.timeline[i]; var ev = room.timeline[i];
if (Unread.eventTriggersUnreadCount(ev) || if (ev.getTs() &&
(ev.sender && ev.sender.userId === MatrixClientPeg.get().credentials.userId)) (Unread.eventTriggersUnreadCount(ev) ||
{ (ev.getSender() === MatrixClientPeg.get().credentials.userId))
) {
return ev.getTs(); return ev.getTs();
} }
} }
@ -166,7 +167,7 @@ var RoomSubList = React.createClass({
// we might only have events that don't trigger the unread indicator, // 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. // 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. // This is better than just assuming the last event was forever ago.
if (room.timeline.length) { if (room.timeline.length && room.timeline[0].getTs()) {
return room.timeline[0].getTs(); return room.timeline[0].getTs();
} else { } else {
return Number.MAX_SAFE_INTEGER; return Number.MAX_SAFE_INTEGER;