From 75fe3c2219c0a7c2857ef4a6417566dcf76a4d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sat, 1 Feb 2020 12:00:04 +0100 Subject: [PATCH 1/2] ManageEventIndexDialog: Show how many rooms are being currently crawled. --- .../eventindex/ManageEventIndexDialog.js | 15 ++++++++--- src/i18n/strings/en_EN.json | 1 + src/indexing/EventIndex.js | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js index 58605a3263..d6e4eb654d 100644 --- a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js +++ b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js @@ -38,6 +38,7 @@ export default class ManageEventIndexDialog extends React.Component { this.state = { eventIndexSize: 0, eventCount: 0, + crawlingRoomsCount: 0, roomCount: 0, currentRoom: null, crawlerSleepTime: @@ -51,11 +52,15 @@ export default class ManageEventIndexDialog extends React.Component { let currentRoom = null; if (room) currentRoom = room.name; + const roomStats = eventIndex.crawlingRooms(); + const crawlingRoomsCount = roomStats.crawlingRooms.size; + const roomCount = roomStats.totalRooms.size; this.setState({ eventIndexSize: stats.size, - roomCount: stats.roomCount, eventCount: stats.eventCount, + crawlingRoomsCount: crawlingRoomsCount, + roomCount: roomCount, currentRoom: currentRoom, }); } @@ -70,6 +75,7 @@ export default class ManageEventIndexDialog extends React.Component { async componentWillMount(): void { let eventIndexSize = 0; + let crawlingRoomsCount = 0; let roomCount = 0; let eventCount = 0; let currentRoom = null; @@ -80,8 +86,10 @@ export default class ManageEventIndexDialog extends React.Component { eventIndex.on("changedCheckpoint", this.updateCurrentRoom.bind(this)); const stats = await eventIndex.getStats(); + const roomStats = eventIndex.crawlingRooms(); eventIndexSize = stats.size; - roomCount = stats.roomCount; + crawlingRoomsCount = roomStats.crawlingRooms.size; + roomCount = roomStats.totalRooms.size; eventCount = stats.eventCount; const room = eventIndex.currentRoom(); @@ -91,6 +99,7 @@ export default class ManageEventIndexDialog extends React.Component { this.setState({ eventIndexSize, eventCount, + crawlingRoomsCount, roomCount, currentRoom, }); @@ -135,7 +144,7 @@ export default class ManageEventIndexDialog extends React.Component {
{_t("Space used:")} {formatBytes(this.state.eventIndexSize, 0)}
{_t("Indexed messages:")} {formatCountLong(this.state.eventCount)}
- {_t("Number of rooms:")} {formatCountLong(this.state.roomCount)}
+ {_t("Number of rooms:")} {formatCountLong(this.state.crawlingRoomsCount)} {_t("of")} {formatCountLong(this.state.roomCount)}
{crawlerState}
{ + 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}; + } } From d8576f23de01ed3ab2ef55b14be478b06f5cc5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Sat, 1 Feb 2020 12:11:49 +0100 Subject: [PATCH 2/2] ManageEventINdexDialog: Fix a line length issue. --- .../views/dialogs/eventindex/ManageEventIndexDialog.js | 3 ++- src/i18n/strings/en_EN.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js index d6e4eb654d..b98fecf22f 100644 --- a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js +++ b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.js @@ -144,7 +144,8 @@ export default class ManageEventIndexDialog extends React.Component {
{_t("Space used:")} {formatBytes(this.state.eventIndexSize, 0)}
{_t("Indexed messages:")} {formatCountLong(this.state.eventCount)}
- {_t("Number of rooms:")} {formatCountLong(this.state.crawlingRoomsCount)} {_t("of")} {formatCountLong(this.state.roomCount)}
+ {_t("Number of rooms:")} {formatCountLong(this.state.crawlingRoomsCount)} {_t("of ")} + {formatCountLong(this.state.roomCount)}
{crawlerState}