From edcef9364ce6a003f1973ebeab44bb288bc80c59 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 10 Aug 2022 12:43:47 +0100 Subject: [PATCH] Only add events if there are some; set the pagination token for faster scrollback --- src/sliding-sync-sdk.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sliding-sync-sdk.ts b/src/sliding-sync-sdk.ts index a32a86e1b..0b8e860e9 100644 --- a/src/sliding-sync-sdk.ts +++ b/src/sliding-sync-sdk.ts @@ -445,8 +445,10 @@ export class SlidingSyncSdk { } } timelineEvents = newEvents; - // old events are scrollback, insert them now - room.addEventsToTimeline(oldEvents, true, room.getLiveTimeline()); + if (oldEvents.length > 0) { + // old events are scrollback, insert them now + room.addEventsToTimeline(oldEvents, true, room.getLiveTimeline(), roomData.prev_batch); + } } const encrypted = this.client.isRoomEncrypted(room.roomId);