Merge branch 'soru/fix-last-event' into 'master'
fix lastEvent See merge request famedly/famedlysdk!301
This commit is contained in:
commit
e50f6cc6c0
|
@ -370,16 +370,15 @@ class Room {
|
||||||
String notificationSettings;
|
String notificationSettings;
|
||||||
|
|
||||||
Event get lastEvent {
|
Event get lastEvent {
|
||||||
var lastTime = DateTime.fromMillisecondsSinceEpoch(0);
|
var lastSortOrder = -1e32; // this bound to be small enough
|
||||||
var lastEvent = getState('m.room.message');
|
var lastEvent = getState('m.room.message');
|
||||||
if (lastEvent == null) {
|
if (lastEvent == null) {
|
||||||
states.forEach((final String key, final entry) {
|
states.forEach((final String key, final entry) {
|
||||||
if (!entry.containsKey('')) return;
|
if (!entry.containsKey('')) return;
|
||||||
final Event state = entry[''];
|
final Event state = entry[''];
|
||||||
if (state.time != null &&
|
if (state.sortOrder != null &&
|
||||||
state.time.millisecondsSinceEpoch >
|
state.sortOrder > lastSortOrder) {
|
||||||
lastTime.millisecondsSinceEpoch) {
|
lastSortOrder = state.sortOrder;
|
||||||
lastTime = state.time;
|
|
||||||
lastEvent = state;
|
lastEvent = state;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue