From f0738a295a42336ec45e3b8c7016c88079613438 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Sun, 7 Dec 2025 22:23:59 +0000 Subject: [PATCH] MessageEventIndexDialog: distinguish indexed rooms (#31436) * MessageEventIndexDialog: comments for state * ManageEventIndexDialog: deduplicate some code `updateCurrentRoom` has the same logic as `componentDidMount`, so let's factor it out. * ManageEventIndexDialog: distinguish indexed rooms Just because a room is not currently awaiting indexing does not mean it has been indexed. Update the dialog to show the actual number of indexed rooms, and the number of rooms that are awaiting indexing. * Apply suggestion from @richvdh --------- Co-authored-by: Will Hunt <2072976+Half-Shot@users.noreply.github.com> --- .../eventindex/ManageEventIndexDialog.tsx | 56 ++++++++----------- src/i18n/strings/en_EN.json | 1 + 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx index d0680fb4cd..ad46048554 100644 --- a/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx +++ b/src/async-components/views/dialogs/eventindex/ManageEventIndexDialog.tsx @@ -26,11 +26,25 @@ interface IProps { } interface IState { + /** Size of the event index, in bytes. */ eventIndexSize: number; + + /** Number of events currently indexed in the event index. */ eventCount: number; + + /** Number of rooms currently mentioned in the event index. */ + eventIndexRoomCount: number; + + /** Number of rooms awaiting crawling by the EventIndex. */ crawlingRoomsCount: number; + + /** Number of encrypted rooms known by the MatrixClient. */ roomCount: number; + + /** Room currently being crawled by the EventIndex. */ currentRoom: string | null; + + /** Time to sleep between crawlwer passes, in milliseconds. */ crawlerSleepTime: number; } @@ -44,6 +58,7 @@ export default class ManageEventIndexDialog extends React.Component => { + public updateCurrentRoom = async (room: Room | null): Promise => { const eventIndex = EventIndexPeg.get(); if (!eventIndex) return; let stats: IIndexStats | undefined; @@ -74,6 +89,7 @@ export default class ManageEventIndexDialog extends React.Component { - let eventIndexSize = 0; - let crawlingRoomsCount = 0; - let roomCount = 0; - let eventCount = 0; - let currentRoom: string | null = null; - const eventIndex = EventIndexPeg.get(); if (eventIndex !== null) { eventIndex.on("changedCheckpoint", this.updateCurrentRoom); - try { - const stats = await eventIndex.getStats(); - if (stats) { - eventIndexSize = stats.size; - eventCount = stats.eventCount; - } - } catch { - // This call may fail if sporadically, not a huge issue as we - // will try later again in the updateCurrentRoom call and - // probably succeed. - } - - const roomStats = eventIndex.crawlingRooms(); - crawlingRoomsCount = roomStats.crawlingRooms.size; - roomCount = roomStats.totalRooms.size; - const room = eventIndex.currentRoom(); - if (room) currentRoom = room.name; + await this.updateCurrentRoom(room); } - - this.setState({ - eventIndexSize, - eventCount, - crawlingRoomsCount, - roomCount, - currentRoom, - }); } private onDisable = async (): Promise => { @@ -149,7 +135,7 @@ export default class ManageEventIndexDialog extends React.Component @@ -169,6 +155,10 @@ export default class ManageEventIndexDialog extends React.Component + {_t("settings|security|message_search_pending_rooms", { + pendingRooms: formatCountLong(this.state.crawlingRoomsCount), + })} +