Skip to content

Commit 91892ec

Browse files
author
Luke Barnard
committed
Do not assume getTs will return comparable integer
Fixes element-hq#3529. In the worst case, tsOfNewestEvent will return MAX_SAFE_INTEGER, instead of undefined, as may be the case of some events that were redacted and persisted in indexDB before changes were made to how events are redacted locally. (The important change is that events are now not stripped of their `origin_server_ts`).
1 parent ff2a9f4 commit 91892ec

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/components/structures/RoomSubList.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,18 @@ var RoomSubList = React.createClass({
156156
tsOfNewestEvent: function(room) {
157157
for (var i = room.timeline.length - 1; i >= 0; --i) {
158158
var ev = room.timeline[i];
159-
if (Unread.eventTriggersUnreadCount(ev) ||
160-
(ev.sender && ev.sender.userId === MatrixClientPeg.get().credentials.userId))
161-
{
159+
if (ev.getTs() &&
160+
(Unread.eventTriggersUnreadCount(ev) ||
161+
(ev.getSender() === MatrixClientPeg.get().credentials.userId))
162+
) {
162163
return ev.getTs();
163164
}
164165
}
165166

166167
// we might only have events that don't trigger the unread indicator,
167168
// in which case use the oldest event even if normally it wouldn't count.
168169
// This is better than just assuming the last event was forever ago.
169-
if (room.timeline.length) {
170+
if (room.timeline.length && room.timeline[0].getTs()) {
170171
return room.timeline[0].getTs();
171172
} else {
172173
return Number.MAX_SAFE_INTEGER;

0 commit comments

Comments
 (0)