Skip to content

Commit 579cd60

Browse files
committed
Reset thread livetimelines when desynced
1 parent 39e1b54 commit 579cd60

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/models/room.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,9 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
11141114
for (const timelineSet of this.timelineSets) {
11151115
timelineSet.resetLiveTimeline(backPaginationToken ?? undefined, forwardPaginationToken ?? undefined);
11161116
}
1117+
for (const thread of this.threads.values()) {
1118+
thread.resetLiveTimeline(backPaginationToken, forwardPaginationToken);
1119+
}
11171120

11181121
this.fixUpLegacyTimelineFields();
11191122
}

src/models/thread.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,21 @@ export class Thread extends ReadReceipt<EmittedEvents, EventHandlerMap> {
358358
this.pendingReplyCount = pendingEvents.length;
359359
}
360360

361+
/**
362+
* Reset the live timeline of all timelineSets, and start new ones.
363+
*
364+
* <p>This is used when /sync returns a 'limited' timeline.
365+
*
366+
* @param backPaginationToken - token for back-paginating the new timeline
367+
* @param forwardPaginationToken - token for forward-paginating the old live timeline,
368+
* if absent or null, all timelines are reset, removing old ones (including the previous live
369+
* timeline which would otherwise be unable to paginate forwards without this token).
370+
* Removing just the old live timeline whilst preserving previous ones is not supported.
371+
*/
372+
public resetLiveTimeline(backPaginationToken?: string | null, forwardPaginationToken?: string | null): void {
373+
this.timelineSet.resetLiveTimeline(backPaginationToken ?? undefined, forwardPaginationToken ?? undefined);
374+
}
375+
361376
private async updateThreadMetadata(): Promise<void> {
362377
this.updatePendingReplyCount();
363378

0 commit comments

Comments
 (0)