jump to latest using empty timeline and back pagination to prevent live message lost
This commit is contained in:
parent
599e938353
commit
bb013ef29e
3 changed files with 6 additions and 18 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -126,4 +126,8 @@ export class TimelineBatchManager {
|
|||
|
||||
this.batch.publish(this.publishKey, newBatch);
|
||||
}
|
||||
|
||||
public reload(batch: MessageBatch) {
|
||||
this.batch.publish(this.publishKey, batch);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue