mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 17:41:25 -08:00
fix(sliding-sync): preserve local echo server order
This commit is contained in:
2 files changed
+41
-1
No files matched your search
@@ -400,7 +400,10 @@ export const prepareSlidingSyncTimelines = (
|
||||
|
||||
if (shouldMarkLimited) timelineData.limited = true;
|
||||
|
||||
const isGapped = firstKnownResponseIndex < 0 || hasSparseOverlap;
|
||||
// The SDK only appends a non-duplicate event from an overlapping response.
|
||||
// Reset when the server window starts before its first known event so those
|
||||
// earlier events are not incorrectly placed at the live tail.
|
||||
const isGapped = firstKnownResponseIndex !== 0;
|
||||
if (
|
||||
knownEventIds.size > 0 &&
|
||||
room &&
|
||||
|
||||
@@ -358,6 +358,43 @@ describe('timeline reconciliation in matrix-js-sdk', () => {
|
||||
expect(localEcho.status).toBeNull();
|
||||
});
|
||||
|
||||
it('places a remote echo before an overlapping newer event', async () => {
|
||||
const { mx, deliver } = makeSdk();
|
||||
await deliver(roomId, initialRoomData(message('$e6', 600)));
|
||||
const room = mx.getRoom(roomId)!;
|
||||
const localEcho = new MatrixEvent({
|
||||
...message('~local', 500),
|
||||
room_id: roomId,
|
||||
sender: userId,
|
||||
});
|
||||
localEcho.setStatus(EventStatus.SENDING);
|
||||
room.addPendingEvent(localEcho, 'txn');
|
||||
|
||||
const resp = {
|
||||
required_state: [],
|
||||
timeline: [
|
||||
{
|
||||
...message('$mine', 500),
|
||||
sender: userId,
|
||||
unsigned: { transaction_id: 'txn' },
|
||||
},
|
||||
message('$e6', 600),
|
||||
],
|
||||
limited: true,
|
||||
prev_batch: 'gap-token',
|
||||
} as unknown as MSC3575RoomData;
|
||||
const completeTimelineReset = prepareSlidingSyncTimelines(
|
||||
{
|
||||
rooms: { [roomId]: resp },
|
||||
} as unknown as MSC3575SlidingSyncResponse,
|
||||
mx
|
||||
);
|
||||
await deliver(roomId, resp);
|
||||
completeTimelineReset?.();
|
||||
|
||||
expect(timelineIds(mx)).toEqual(['$mine', '$e6']);
|
||||
});
|
||||
|
||||
it('starts a new live timeline when an expanded catch-up has no overlap', async () => {
|
||||
const { mx, deliver } = makeSdk();
|
||||
await deliver(roomId, initialRoomData(newest));
|
||||
|
||||
Reference in new issue
Block a user