From 5989a21dfb97e0804b94bae503b2637e6d2dd7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 13 Oct 2020 16:02:05 +0200 Subject: [PATCH] event-index: Pass the user/device id pair when initializing the event index. --- src/indexing/BaseEventIndexManager.ts | 5 ++++- src/indexing/EventIndexPeg.js | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/indexing/BaseEventIndexManager.ts b/src/indexing/BaseEventIndexManager.ts index 64cf01bd6e..df14f84622 100644 --- a/src/indexing/BaseEventIndexManager.ts +++ b/src/indexing/BaseEventIndexManager.ts @@ -105,10 +105,13 @@ export default abstract class BaseEventIndexManager { /** * Initialize the event index for the given user. * + * @param {string} user_id The event that should be added to the index. + * @param {string} device_id The profile of the event sender at the + * * @return {Promise} A promise that will resolve when the event index is * initialized. */ - async initEventIndex(): Promise { + async initEventIndex(user_id: string, device_id: string): Promise { throw new Error("Unimplemented"); } diff --git a/src/indexing/EventIndexPeg.js b/src/indexing/EventIndexPeg.js index 58e8430825..6acc6caa10 100644 --- a/src/indexing/EventIndexPeg.js +++ b/src/indexing/EventIndexPeg.js @@ -21,6 +21,7 @@ limitations under the License. import PlatformPeg from "../PlatformPeg"; import EventIndex from "../indexing/EventIndex"; +import {MatrixClientPeg} from "../MatrixClientPeg"; import SettingsStore from '../settings/SettingsStore'; import {SettingLevel} from "../settings/SettingLevel"; @@ -70,9 +71,13 @@ class EventIndexPeg { async initEventIndex() { const index = new EventIndex(); const indexManager = PlatformPeg.get().getEventIndexingManager(); + const client = MatrixClientPeg.get(); + + const user_id = client.getUserId(); + const device_id = client.getDeviceId(); try { - await indexManager.initEventIndex(); + await indexManager.initEventIndex(user_id, device_id); const userVersion = await indexManager.getUserVersion(); const eventIndexIsEmpty = await indexManager.isEventIndexEmpty(); @@ -83,7 +88,7 @@ class EventIndexPeg { await indexManager.closeEventIndex(); await this.deleteEventIndex(); - await indexManager.initEventIndex(); + await indexManager.initEventIndex(user_id, device_id); await indexManager.setUserVersion(INDEX_VERSION); }