EventIndexing: Check if there is a room when resetting the timeline.

This commit is contained in:
Damir Jelić 2019-11-13 15:23:08 +01:00
parent f453fea24a
commit 1316e04776
2 changed files with 4 additions and 13 deletions

View file

@ -347,7 +347,7 @@ export default class EventIndexer {
console.log("Seshat: Stopping crawler function"); console.log("Seshat: Stopping crawler function");
} }
async addCheckpointForLimitedRoom(room) { async onLimitedTimeline(room) {
const indexManager = PlatformPeg.get().getEventIndexingManager(); const indexManager = PlatformPeg.get().getEventIndexingManager();
if (indexManager === null) return; if (indexManager === null) return;
if (!MatrixClientPeg.get().isRoomEncrypted(room.roomId)) return; if (!MatrixClientPeg.get().isRoomEncrypted(room.roomId)) return;
@ -362,21 +362,12 @@ export default class EventIndexer {
direction: "b", direction: "b",
}; };
const forwardsCheckpoint = {
roomId: room.roomId,
token: token,
fullCrawl: false,
direction: "f",
};
console.log("Seshat: Added checkpoint because of a limited timeline", console.log("Seshat: Added checkpoint because of a limited timeline",
backwardsCheckpoint, forwardsCheckpoint); backwardsCheckpoint);
await indexManager.addCrawlerCheckpoint(backwardsCheckpoint); await indexManager.addCrawlerCheckpoint(backwardsCheckpoint);
await indexManager.addCrawlerCheckpoint(forwardsCheckpoint);
this.crawlerChekpoints.push(backwardsCheckpoint); this.crawlerChekpoints.push(backwardsCheckpoint);
this.crawlerChekpoints.push(forwardsCheckpoint);
} }
async deleteEventIndex() { async deleteEventIndex() {

View file

@ -1310,8 +1310,8 @@ export default createReactClass({
cli.on("Room.timelineReset", async (room, timelineSet, resetAllTimelines) => { cli.on("Room.timelineReset", async (room, timelineSet, resetAllTimelines) => {
const eventIndex = EventIndexPeg.get(); const eventIndex = EventIndexPeg.get();
if (eventIndex === null) return; if (eventIndex === null) return;
if (resetAllTimelines === true) return; if (room === null) return;
await eventIndex.addCheckpointForLimitedRoom(room); await eventIndex.onLimitedTimeline(room);
}); });
cli.on('sync', function(state, prevState, data) { cli.on('sync', function(state, prevState, data) {