EventIndex: Refactor out the addInitialCheckpoints method.
This commit is contained in:
parent
47ea453abf
commit
4627e3b282
1 changed files with 47 additions and 47 deletions
|
@ -70,11 +70,10 @@ export default class EventIndex {
|
||||||
client.removeListener('Room.timelineReset', this.onTimelineReset);
|
client.removeListener('Room.timelineReset', this.onTimelineReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSync = async (state, prevState, data) => {
|
/** Get crawler checkpoints for the encrypted rooms and store them in the index.
|
||||||
|
*/
|
||||||
|
async addInitialCheckpoints() {
|
||||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
|
|
||||||
if (prevState === "PREPARED" && state === "SYNCING") {
|
|
||||||
const addInitialCheckpoints = async () => {
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const rooms = client.getRooms();
|
const rooms = client.getRooms();
|
||||||
|
|
||||||
|
@ -114,18 +113,19 @@ export default class EventIndex {
|
||||||
this.crawlerCheckpoints.push(backCheckpoint);
|
this.crawlerCheckpoints.push(backCheckpoint);
|
||||||
this.crawlerCheckpoints.push(forwardCheckpoint);
|
this.crawlerCheckpoints.push(forwardCheckpoint);
|
||||||
}));
|
}));
|
||||||
};
|
}
|
||||||
|
|
||||||
|
onSync = async (state, prevState, data) => {
|
||||||
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
|
|
||||||
|
if (prevState === "PREPARED" && state === "SYNCING") {
|
||||||
// If our indexer is empty we're most likely running Riot the
|
// If our indexer is empty we're most likely running Riot the
|
||||||
// first time with indexing support or running it with an
|
// first time with indexing support or running it with an
|
||||||
// initial sync. Add checkpoints to crawl our encrypted rooms.
|
// initial sync. Add checkpoints to crawl our encrypted rooms.
|
||||||
const eventIndexWasEmpty = await indexManager.isEventIndexEmpty();
|
const eventIndexWasEmpty = await indexManager.isEventIndexEmpty();
|
||||||
if (eventIndexWasEmpty) await addInitialCheckpoints();
|
if (eventIndexWasEmpty) await this.addInitialCheckpoints();
|
||||||
|
|
||||||
// Start our crawler.
|
|
||||||
if (SettingsStore.getValueAt(SettingLevel.DEVICE, 'enableCrawling')) {
|
|
||||||
this.startCrawler();
|
this.startCrawler();
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue