Merge branch 'room-fix-lastevent-calc' into 'master'

[Room] Fix last event calculation

See merge request famedly/famedlysdk!117
This commit is contained in:
Christian Pauly 2019-11-13 14:08:27 +00:00
commit dcb1c42044

View file

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