MatrixChat: Add new crawler checkpoints if there was a limited timeline.
A sync call may not have all events that happened since the last time the client synced. In such a case the room is marked as limited and events need to be fetched separately. When such a sync call happens our event index will have a gap. To close the gap checkpoints are added to start crawling our room again. Unnecessary full re-crawls are prevented by checking if our current /room/roomId/messages request contains only events that were already present in our event index.
This commit is contained in:
parent
5e7076e985
commit
4acec19d40
1 changed files with 41 additions and 1 deletions
|
@ -1281,8 +1281,11 @@ export default createReactClass({
|
||||||
// particularly noticeable when there are lots of 'limited' /sync responses
|
// particularly noticeable when there are lots of 'limited' /sync responses
|
||||||
// such as when laptops unsleep.
|
// such as when laptops unsleep.
|
||||||
// https://github.com/vector-im/riot-web/issues/3307#issuecomment-282895568
|
// https://github.com/vector-im/riot-web/issues/3307#issuecomment-282895568
|
||||||
cli.setCanResetTimelineCallback(function(roomId) {
|
cli.setCanResetTimelineCallback(async function(roomId) {
|
||||||
console.log("Request to reset timeline in room ", roomId, " viewing:", self.state.currentRoomId);
|
console.log("Request to reset timeline in room ", roomId, " viewing:", self.state.currentRoomId);
|
||||||
|
// TODO is there a better place to plug this in
|
||||||
|
await self.addCheckpointForLimitedRoom(roomId);
|
||||||
|
|
||||||
if (roomId !== self.state.currentRoomId) {
|
if (roomId !== self.state.currentRoomId) {
|
||||||
// It is safe to remove events from rooms we are not viewing.
|
// It is safe to remove events from rooms we are not viewing.
|
||||||
return true;
|
return true;
|
||||||
|
@ -2234,4 +2237,41 @@ export default createReactClass({
|
||||||
|
|
||||||
console.log("Seshat: Stopping crawler function");
|
console.log("Seshat: Stopping crawler function");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async addCheckpointForLimitedRoom(roomId) {
|
||||||
|
const platform = PlatformPeg.get();
|
||||||
|
if (!platform.supportsEventIndexing()) return;
|
||||||
|
if (!MatrixClientPeg.get().isRoomEncrypted(roomId)) return;
|
||||||
|
|
||||||
|
const client = MatrixClientPeg.get();
|
||||||
|
const room = client.getRoom(roomId);
|
||||||
|
|
||||||
|
if (room === null) return;
|
||||||
|
|
||||||
|
const timeline = room.getLiveTimeline();
|
||||||
|
const token = timeline.getPaginationToken("b");
|
||||||
|
|
||||||
|
const backwardsCheckpoint = {
|
||||||
|
roomId: room.roomId,
|
||||||
|
token: token,
|
||||||
|
fullCrawl: false,
|
||||||
|
direction: "b",
|
||||||
|
};
|
||||||
|
|
||||||
|
const forwardsCheckpoint = {
|
||||||
|
roomId: room.roomId,
|
||||||
|
token: token,
|
||||||
|
fullCrawl: false,
|
||||||
|
direction: "f",
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("Seshat: Added checkpoint because of a limited timeline",
|
||||||
|
backwardsCheckpoint, forwardsCheckpoint);
|
||||||
|
|
||||||
|
await platform.addCrawlerCheckpoint(backwardsCheckpoint);
|
||||||
|
await platform.addCrawlerCheckpoint(forwardsCheckpoint);
|
||||||
|
|
||||||
|
this.crawlerChekpoints.push(backwardsCheckpoint);
|
||||||
|
this.crawlerChekpoints.push(forwardsCheckpoint);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue