jump to latest using empty timeline and back pagination to prevent live message lost

This commit is contained in:
Ajay Bura 2026-08-17 14:59:55 +05:30
commit bb013ef29e
3 changed files with 6 additions and 18 deletions

View file

@ -288,15 +288,8 @@ export class ThreadTimeline implements TimelineView, Disposable {
this.range.setRange(MessageRange.atLiveEnd(this.batch.read.size));
return;
}
const [err, result] = await this.getMessages(undefined, 'b', 80);
if (err) {
throw new Error(printMatrixError(err));
}
const { next_batch: prevToken, prev_batch: endToken, chunk } = result;
const messageEvents: MessageEventWithoutRoomId[] = this.relations.pickAndFilter(chunk);
this.batchManager.loadEvents(messageEvents, prevToken, endToken);
this.batchManager.reload(MessageBatch.emptyAtForwardEnd());
}
public findEvent(eventId: string): MessageEventWithoutRoomId | undefined {

View file

@ -281,17 +281,8 @@ export class Timeline implements TimelineView, Disposable {
this.range.setRange(MessageRange.atLiveEnd(this.batch.read.size));
return;
}
const [err, result] = await this.getMessages(undefined, 'b', 80);
if (err) {
throw new Error(printMatrixError(err));
}
const { end: prevToken, start: endToken, chunk } = result;
const messageEvents: MessageEventWithoutRoomId[] = this.relations.pickAndFilter(chunk);
this.pickThreads(messageEvents);
this.batchManager.loadEvents(messageEvents, prevToken, endToken);
this.batchManager.reload(MessageBatch.emptyAtForwardEnd());
}
public findEvent(eventId: string): MessageEventWithoutRoomId | undefined {

View file

@ -126,4 +126,8 @@ export class TimelineBatchManager {
this.batch.publish(this.publishKey, newBatch);
}
public reload(batch: MessageBatch) {
this.batch.publish(this.publishKey, batch);
}
}