Merge pull request #2054 from famedly/td/setPrevBatchWhenInSync
fix: set prev_batch when seen in sync
This commit is contained in:
commit
3f4c9da90b
|
|
@ -594,7 +594,7 @@ class FakeMatrixApi extends BaseClient {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'limited': true,
|
'limited': true,
|
||||||
'prev_batch': 't34-23535_0_0',
|
'prev_batch': 't44-23535_0_0',
|
||||||
},
|
},
|
||||||
'ephemeral': {
|
'ephemeral': {
|
||||||
'events': [
|
'events': [
|
||||||
|
|
@ -711,7 +711,7 @@ class FakeMatrixApi extends BaseClient {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'limited': true,
|
'limited': true,
|
||||||
'prev_batch': 't34-23535_0_0',
|
'prev_batch': 't34-23535_0_1',
|
||||||
},
|
},
|
||||||
'account_data': {
|
'account_data': {
|
||||||
'events': [
|
'events': [
|
||||||
|
|
|
||||||
|
|
@ -2989,7 +2989,9 @@ class Client extends MatrixApi {
|
||||||
chatUpdate.unreadNotifications?.notificationCount ?? 0;
|
chatUpdate.unreadNotifications?.notificationCount ?? 0;
|
||||||
rooms[roomIndex].highlightCount =
|
rooms[roomIndex].highlightCount =
|
||||||
chatUpdate.unreadNotifications?.highlightCount ?? 0;
|
chatUpdate.unreadNotifications?.highlightCount ?? 0;
|
||||||
|
if (chatUpdate.timeline?.prevBatch != null) {
|
||||||
|
rooms[roomIndex].prev_batch = chatUpdate.timeline?.prevBatch;
|
||||||
|
}
|
||||||
final summary = chatUpdate.summary;
|
final summary = chatUpdate.summary;
|
||||||
if (summary != null) {
|
if (summary != null) {
|
||||||
final roomSummaryJson = rooms[roomIndex].summary.toJson()
|
final roomSummaryJson = rooms[roomIndex].summary.toJson()
|
||||||
|
|
|
||||||
|
|
@ -761,6 +761,31 @@ void main() {
|
||||||
expect(room.lastEvent!.content['body'], '* foxies');
|
expect(room.lastEvent!.content['body'], '* foxies');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('set prev_batch if in sync', () async {
|
||||||
|
final roomId = '!726s6s6q:example.com';
|
||||||
|
final room = matrix.getRoomById(roomId)!;
|
||||||
|
|
||||||
|
expect(room.prev_batch, 't44-23535_0_0');
|
||||||
|
// put an important state event in-memory
|
||||||
|
await matrix.handleSync(
|
||||||
|
SyncUpdate.fromJson({
|
||||||
|
'next_batch': 'fakesync',
|
||||||
|
'rooms': {
|
||||||
|
'join': {
|
||||||
|
roomId: {
|
||||||
|
'timeline': {
|
||||||
|
'events': [],
|
||||||
|
'prev_batch': 'prev_batch_1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(room.prev_batch, 'prev_batch_1');
|
||||||
|
});
|
||||||
|
|
||||||
test('getProfileFromUserId', () async {
|
test('getProfileFromUserId', () async {
|
||||||
final cachedProfile = await matrix.getUserProfile('@getme:example.com');
|
final cachedProfile = await matrix.getUserProfile('@getme:example.com');
|
||||||
expect(cachedProfile.outdated, false);
|
expect(cachedProfile.outdated, false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue