diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js --- a/lib/types/store-ops-types.js +++ b/lib/types/store-ops-types.js @@ -12,6 +12,7 @@ import type { ClientReportCreationRequest } from './report-types.js'; import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js'; import type { UserInfos } from './user-types.js'; +import type { ClientDBKeyserverInfo } from '../ops/keyserver-store-ops.js'; import type { ClientDBMessageStoreOperation, MessageStoreOperation, @@ -52,6 +53,7 @@ +messageStoreThreads: $ReadOnlyArray, +reports: $ReadOnlyArray, +users: $ReadOnlyArray, + +keyservers: $ReadOnlyArray, }; export type ClientStore = { diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp @@ -115,6 +115,7 @@ std::vector messageStoreThreadsVector; std::vector reportStoreVector; std::vector userStoreVector; + std::vector keyserverStoreVector; try { draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts(); messagesVector = @@ -125,6 +126,8 @@ reportStoreVector = DatabaseManager::getQueryExecutor().getAllReports(); userStoreVector = DatabaseManager::getQueryExecutor().getAllUsers(); + keyserverStoreVector = + DatabaseManager::getQueryExecutor().getAllKeyservers(); } catch (std::system_error &e) { error = e.what(); } @@ -142,6 +145,9 @@ std::move(reportStoreVector)); auto userStoreVectorPtr = std::make_shared>( std::move(userStoreVector)); + auto keyserveStoreVectorPtr = + std::make_shared>( + std::move(keyserverStoreVector)); this->jsInvoker_->invokeAsync([&innerRt, draftsVectorPtr, messagesVectorPtr, @@ -149,13 +155,16 @@ messageStoreThreadsVectorPtr, reportStoreVectorPtr, userStoreVectorPtr, + keyserveStoreVectorPtr, error, promise, draftStore = this->draftStore, threadStore = this->threadStore, messageStore = this->messageStore, reportStore = this->reportStore, - userStore = this->userStore]() { + userStore = this->userStore, + keyserverStore = + this->keyserverStore]() { if (error.size()) { promise->reject(error); return; @@ -173,6 +182,8 @@ reportStore.parseDBDataStore(innerRt, reportStoreVectorPtr); jsi::Array jsiUserStore = userStore.parseDBDataStore(innerRt, userStoreVectorPtr); + jsi::Array jsiKeyserverStore = keyserverStore.parseDBDataStore( + innerRt, keyserveStoreVectorPtr); auto jsiClientDBStore = jsi::Object(innerRt); jsiClientDBStore.setProperty(innerRt, "messages", jsiMessages); @@ -182,6 +193,8 @@ innerRt, "messageStoreThreads", jsiMessageStoreThreads); jsiClientDBStore.setProperty(innerRt, "reports", jsiReportStore); jsiClientDBStore.setProperty(innerRt, "users", jsiUserStore); + jsiClientDBStore.setProperty( + innerRt, "keyservers", jsiKeyserverStore); promise->resolve(std::move(jsiClientDBStore)); }); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/KeyserverStore.cpp @@ -17,7 +17,15 @@ jsi::Array KeyserverStore::parseDBDataStore( jsi::Runtime &rt, std::shared_ptr> keyserversVectorPtr) const { - jsi::Array jsiKeyservers = jsi::Array(rt, 0); + size_t numKeyservers = keyserversVectorPtr->size(); + jsi::Array jsiKeyservers = jsi::Array(rt, numKeyservers); + size_t writeIdx = 0; + for (const KeyserverInfo &keyserver : *keyserversVectorPtr) { + jsi::Object jsiKeyserver = jsi::Object(rt); + jsiKeyserver.setProperty(rt, "id", keyserver.id); + jsiKeyserver.setProperty(rt, "keyserverInfo", keyserver.keyserver_info); + jsiKeyservers.setValueAtIndex(rt, writeIdx++, jsiKeyserver); + } return jsiKeyservers; } diff --git a/web/database/worker/process-operations.js b/web/database/worker/process-operations.js --- a/web/database/worker/process-operations.js +++ b/web/database/worker/process-operations.js @@ -170,6 +170,7 @@ messageStoreThreads: [], reports: sqliteQueryExecutor.getAllReports(), users: [], + keyservers: [], }; }