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 @@ -19,6 +19,7 @@ ClientDBCommunityStoreOperation, CommunityStoreOperation, } from '../ops/community-store-ops.js'; +import type { ClientDBIntegrityThreadHash } from '../ops/integrity-store-ops.js'; import type { ClientDBKeyserverInfo, ClientDBKeyserverStoreOperation, @@ -70,6 +71,7 @@ +users: $ReadOnlyArray, +keyservers: $ReadOnlyArray, +communities: $ReadOnlyArray, + +integrityThreadHashes: $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 @@ -119,6 +119,7 @@ std::vector userStoreVector; std::vector keyserverStoreVector; std::vector communityStoreVector; + std::vector integrityStoreVector; try { draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts(); messagesVector = @@ -133,6 +134,8 @@ DatabaseManager::getQueryExecutor().getAllKeyservers(); communityStoreVector = DatabaseManager::getQueryExecutor().getAllCommunities(); + integrityStoreVector = DatabaseManager::getQueryExecutor() + .getAllIntegrityThreadHashes(); } catch (std::system_error &e) { error = e.what(); } @@ -156,6 +159,9 @@ auto communityStoreVectorPtr = std::make_shared>( std::move(communityStoreVector)); + auto integrityStoreVectorPtr = + std::make_shared>( + std::move(integrityStoreVector)); this->jsInvoker_->invokeAsync([&innerRt, draftsVectorPtr, messagesVectorPtr, @@ -165,6 +171,7 @@ userStoreVectorPtr, keyserveStoreVectorPtr, communityStoreVectorPtr, + integrityStoreVectorPtr, error, promise, draftStore = this->draftStore, @@ -173,8 +180,9 @@ reportStore = this->reportStore, userStore = this->userStore, keyserverStore = this->keyserverStore, - communityStore = - this->communityStore]() { + communityStore = this->communityStore, + integrityStore = + this->integrityStore]() { if (error.size()) { promise->reject(error); return; @@ -196,6 +204,8 @@ innerRt, keyserveStoreVectorPtr); jsi::Array jsiCommunityStore = communityStore.parseDBDataStore( innerRt, communityStoreVectorPtr); + jsi::Array jsiIntegrityStore = integrityStore.parseDBDataStore( + innerRt, integrityStoreVectorPtr); auto jsiClientDBStore = jsi::Object(innerRt); jsiClientDBStore.setProperty(innerRt, "messages", jsiMessages); @@ -209,6 +219,8 @@ innerRt, "keyservers", jsiKeyserverStore); jsiClientDBStore.setProperty( innerRt, "communities", jsiCommunityStore); + jsiClientDBStore.setProperty( + innerRt, "integrityThreadHashes", jsiIntegrityStore); promise->resolve(std::move(jsiClientDBStore)); }); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/IntegrityStore.cpp @@ -22,7 +22,19 @@ jsi::Runtime &rt, std::shared_ptr> integrityThreadHashesVectorPtr) const { - jsi::Array jsiIntegrityThreadHashes = jsi::Array(rt, 0); + size_t numIntegrityThreadHashes = integrityThreadHashesVectorPtr->size(); + jsi::Array jsiIntegrityThreadHashes = + jsi::Array(rt, numIntegrityThreadHashes); + size_t writeIdx = 0; + for (const IntegrityThreadHash &integrityThreadHash : + *integrityThreadHashesVectorPtr) { + jsi::Object jsiIntegrityThreadHash = jsi::Object(rt); + jsiIntegrityThreadHash.setProperty(rt, "id", integrityThreadHash.id); + jsiIntegrityThreadHash.setProperty( + rt, "threadHash", integrityThreadHash.thread_hash); + jsiIntegrityThreadHashes.setValueAtIndex( + rt, writeIdx++, jsiIntegrityThreadHash); + } return jsiIntegrityThreadHashes; } diff --git a/web/shared-worker/worker/process-operations.js b/web/shared-worker/worker/process-operations.js --- a/web/shared-worker/worker/process-operations.js +++ b/web/shared-worker/worker/process-operations.js @@ -258,6 +258,7 @@ users: [], keyservers: sqliteQueryExecutor.getAllKeyservers(), communities: sqliteQueryExecutor.getAllCommunities(), + integrityThreadHashes: [], }; }