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 @@ -16,6 +16,7 @@ import type { SyncedMetadata } from './synced-metadata-types.js'; import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js'; import type { UserInfos } from './user-types.js'; +import type { ClientDBAuxUserInfo } from '../ops/aux-user-store-ops.js'; import type { ClientDBCommunityInfo, ClientDBCommunityStoreOperation, @@ -87,6 +88,7 @@ +communities: $ReadOnlyArray, +integrityThreadHashes: $ReadOnlyArray, +syncedMetadata: $ReadOnlyArray, + +auxUserInfos: $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 @@ -121,6 +121,7 @@ std::vector communityStoreVector; std::vector integrityStoreVector; std::vector syncedMetadataStoreVector; + std::vector auxUserStoreVector; try { draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts(); messagesVector = @@ -139,7 +140,8 @@ .getAllIntegrityThreadHashes(); syncedMetadataStoreVector = DatabaseManager::getQueryExecutor().getAllSyncedMetadata(); - + auxUserStoreVector = + DatabaseManager::getQueryExecutor().getAllAuxUserInfos(); } catch (std::system_error &e) { error = e.what(); } @@ -169,6 +171,9 @@ auto syncedMetadataStoreVectorPtr = std::make_shared>( std::move(syncedMetadataStoreVector)); + auto auxUserStoreVectorPtr = + std::make_shared>( + std::move(auxUserStoreVector)); this->jsInvoker_->invokeAsync([&innerRt, draftsVectorPtr, messagesVectorPtr, @@ -180,6 +185,7 @@ communityStoreVectorPtr, integrityStoreVectorPtr, syncedMetadataStoreVectorPtr, + auxUserStoreVectorPtr, error, promise, draftStore = this->draftStore, @@ -191,7 +197,8 @@ communityStore = this->communityStore, integrityStore = this->integrityStore, syncedMetadataStore = - this->syncedMetadataStore]() { + this->syncedMetadataStore, + auxUserStore = this->auxUserStore]() { if (error.size()) { promise->reject(error); return; @@ -218,6 +225,8 @@ jsi::Array jsiSyncedMetadataStore = syncedMetadataStore.parseDBDataStore( innerRt, syncedMetadataStoreVectorPtr); + jsi::Array jsiAuxUserStore = + auxUserStore.parseDBDataStore(innerRt, auxUserStoreVectorPtr); auto jsiClientDBStore = jsi::Object(innerRt); jsiClientDBStore.setProperty(innerRt, "messages", jsiMessages); @@ -235,6 +244,8 @@ innerRt, "integrityThreadHashes", jsiIntegrityStore); jsiClientDBStore.setProperty( innerRt, "syncedMetadata", jsiSyncedMetadataStore); + jsiClientDBStore.setProperty( + innerRt, "auxUserInfos", jsiAuxUserStore); promise->resolve(std::move(jsiClientDBStore)); }); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/AuxUserStore.cpp @@ -17,7 +17,16 @@ jsi::Array AuxUserStore::parseDBDataStore( jsi::Runtime &rt, std::shared_ptr> auxUserInfosVectorPtr) const { - jsi::Array jsiAuxUserInfos = jsi::Array(rt, 0); + + size_t numAuxUserInfos = auxUserInfosVectorPtr->size(); + jsi::Array jsiAuxUserInfos = jsi::Array(rt, numAuxUserInfos); + size_t writeIdx = 0; + for (const AuxUserInfo &auxUserInfo : *auxUserInfosVectorPtr) { + jsi::Object jsiAuxUserInfo = jsi::Object(rt); + jsiAuxUserInfo.setProperty(rt, "id", auxUserInfo.id); + jsiAuxUserInfo.setProperty(rt, "auxUserInfo", auxUserInfo.aux_user_info); + jsiAuxUserInfos.setValueAtIndex(rt, writeIdx++, jsiAuxUserInfo); + } return jsiAuxUserInfos; } 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 @@ -347,6 +347,7 @@ communities: sqliteQueryExecutor.getAllCommunities(), integrityThreadHashes: sqliteQueryExecutor.getAllIntegrityThreadHashes(), syncedMetadata: sqliteQueryExecutor.getAllSyncedMetadata(), + auxUserInfos: [], }; }