[Room] Fix last event calculation

This commit is contained in:
Christian Pauly 2019-11-13 14:08:27 +00:00
parent 83e45bb719
commit 7a3056f741

View file

@ -156,12 +156,17 @@ class Room {
Event get lastEvent { Event get lastEvent {
ChatTime lastTime = ChatTime(0); ChatTime lastTime = ChatTime(0);
Event lastEvent = null; Event lastEvent = null;
states.forEach((String key, RoomState state) { for (final entry in states.entries) {
if (state.time != null && state.time > lastTime) { final RoomState state = entry.value;
if ((state.time != null && state.time > lastTime) ||
state.typeKey == "m.room.message") {
lastTime = state.time; lastTime = state.time;
lastEvent = state.timelineEvent; lastEvent = state.timelineEvent;
if (state.typeKey == "m.room.message") {
break;
}
}
} }
});
return lastEvent; return lastEvent;
} }