You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-10 09:22:25 +03:00
EventIndex: Add a method to gather the currently crawled rooms.
This commit is contained in:
@@ -33,6 +33,7 @@ export default class EventIndex {
|
|||||||
// crawl.
|
// crawl.
|
||||||
this._eventsPerCrawl = 100;
|
this._eventsPerCrawl = 100;
|
||||||
this._crawler = null;
|
this._crawler = null;
|
||||||
|
this._currentCheckpoint = null;
|
||||||
this.liveEventsForIndex = new Set();
|
this.liveEventsForIndex = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +214,8 @@ export default class EventIndex {
|
|||||||
sleepTime = this._crawlerIdleTime;
|
sleepTime = this._crawlerIdleTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._currentCheckpoint = null;
|
||||||
|
|
||||||
await sleep(sleepTime);
|
await sleep(sleepTime);
|
||||||
|
|
||||||
console.log("EventIndex: Running the crawler loop.");
|
console.log("EventIndex: Running the crawler loop.");
|
||||||
@@ -230,6 +233,8 @@ export default class EventIndex {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._currentCheckpoint = checkpoint;
|
||||||
|
|
||||||
idle = false;
|
idle = false;
|
||||||
|
|
||||||
console.log("EventIndex: crawling using checkpoint", checkpoint);
|
console.log("EventIndex: crawling using checkpoint", checkpoint);
|
||||||
@@ -424,4 +429,31 @@ export default class EventIndex {
|
|||||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||||
return indexManager.indexSize();
|
return indexManager.indexSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentlyCrawledRooms() {
|
||||||
|
let crawlingRooms = new Set();
|
||||||
|
let totalRooms = new Set();
|
||||||
|
|
||||||
|
this.crawlerCheckpoints.forEach((checkpoint, index) => {
|
||||||
|
crawlingRooms.add(checkpoint.roomId);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this._currentCheckpoint !== null) {
|
||||||
|
crawlingRooms.add(this._currentCheckpoint.roomId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const client = MatrixClientPeg.get();
|
||||||
|
const rooms = client.getRooms();
|
||||||
|
|
||||||
|
const isRoomEncrypted = (room) => {
|
||||||
|
return client.isRoomEncrypted(room.roomId);
|
||||||
|
};
|
||||||
|
|
||||||
|
const encryptedRooms = rooms.filter(isRoomEncrypted);
|
||||||
|
encryptedRooms.forEach((room, index) => {
|
||||||
|
totalRooms.add(room.roomId);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {crawlingRooms, totalRooms}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user