mirror of
https://github.com/cinnyapp/cinny.git
synced 2026-11-26 03:46:36 -08:00
jump to latest using empty timeline and back pagination to prevent live message lost
This commit is contained in:
1 parent
599e938353
commit
bb013ef29e
3 files changed
+6
-18
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user