[Store] Async storing of prev batch
This commit is contained in:
parent
3fbb837f85
commit
4d1e5e3ed3
|
@ -721,13 +721,16 @@ class Client {
|
||||||
if (this.store != null) {
|
if (this.store != null) {
|
||||||
await this.store.transaction(() {
|
await this.store.transaction(() {
|
||||||
handleSync(syncResp);
|
handleSync(syncResp);
|
||||||
this.store.storePrevBatch(syncResp);
|
this.store.storePrevBatch(syncResp["next_batch"]);
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await handleSync(syncResp);
|
await handleSync(syncResp);
|
||||||
}
|
}
|
||||||
if (this.prevBatch == null) this.onFirstSync.add(true);
|
if (this.prevBatch == null) {
|
||||||
|
this.onFirstSync.add(true);
|
||||||
|
this.prevBatch = syncResp["next_batch"];
|
||||||
|
_sortRooms();
|
||||||
|
}
|
||||||
this.prevBatch = syncResp["next_batch"];
|
this.prevBatch = syncResp["next_batch"];
|
||||||
if (hash == _syncRequest.hashCode) unawaited(_sync());
|
if (hash == _syncRequest.hashCode) unawaited(_sync());
|
||||||
} on MatrixException catch (exception) {
|
} on MatrixException catch (exception) {
|
||||||
|
@ -1042,7 +1045,7 @@ class Client {
|
||||||
.compareTo(a.timeCreated.millisecondsSinceEpoch);
|
.compareTo(a.timeCreated.millisecondsSinceEpoch);
|
||||||
|
|
||||||
_sortRooms() {
|
_sortRooms() {
|
||||||
if (_sortLock || rooms.length < 2) return;
|
if (prevBatch == null || _sortLock || rooms.length < 2) return;
|
||||||
_sortLock = true;
|
_sortLock = true;
|
||||||
rooms?.sort(sortRoomsBy);
|
rooms?.sort(sortRoomsBy);
|
||||||
_sortLock = false;
|
_sortLock = false;
|
||||||
|
|
|
@ -48,11 +48,11 @@ abstract class StoreAPI {
|
||||||
|
|
||||||
var txn;
|
var txn;
|
||||||
|
|
||||||
Future<void> transaction(Future<void> queries());
|
Future<void> transaction(void queries());
|
||||||
|
|
||||||
/// Will be automatically called on every synchronisation. Must be called inside of
|
/// Will be automatically called on every synchronisation. Must be called inside of
|
||||||
// /// [transaction].
|
// /// [transaction].
|
||||||
Future<void> storePrevBatch(dynamic sync);
|
void storePrevBatch(String prevBatch);
|
||||||
|
|
||||||
Future<void> storeRoomPrevBatch(Room room);
|
Future<void> storeRoomPrevBatch(Room room);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue