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 @@ -23,7 +23,10 @@ ClientDBThreadStoreOperation, ThreadStoreOperation, } from '../ops/thread-store-ops.js'; -import type { UserStoreOperation } from '../ops/user-store-ops.js'; +import type { + UserStoreOperation, + ClientDBUserInfo, +} from '../ops/user-store-ops.js'; export type StoreOperations = { +draftStoreOperations: $ReadOnlyArray, @@ -46,4 +49,5 @@ +threads: $ReadOnlyArray, +messageStoreThreads: $ReadOnlyArray, +reports: $ReadOnlyArray, + +users: $ReadOnlyArray, }; 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 @@ -113,6 +113,7 @@ std::vector>> messagesVector; std::vector messageStoreThreadsVector; std::vector reportStoreVector; + std::vector userStoreVector; try { draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts(); messagesVector = @@ -122,6 +123,7 @@ DatabaseManager::getQueryExecutor().getAllMessageStoreThreads(); reportStoreVector = DatabaseManager::getQueryExecutor().getAllReports(); + userStoreVector = DatabaseManager::getQueryExecutor().getAllUsers(); } catch (std::system_error &e) { error = e.what(); } @@ -137,18 +139,22 @@ std::move(messageStoreThreadsVector)); auto reportStoreVectorPtr = std::make_shared>( std::move(reportStoreVector)); + auto userStoreVectorPtr = std::make_shared>( + std::move(userStoreVector)); this->jsInvoker_->invokeAsync([&innerRt, draftsVectorPtr, messagesVectorPtr, threadsVectorPtr, messageStoreThreadsVectorPtr, reportStoreVectorPtr, + userStoreVectorPtr, error, promise, draftStore = this->draftStore, threadStore = this->threadStore, messageStore = this->messageStore, - reportStore = this->reportStore]() { + reportStore = this->reportStore, + userStore = this->userStore]() { if (error.size()) { promise->reject(error); return; @@ -164,6 +170,8 @@ innerRt, messageStoreThreadsVectorPtr); jsi::Array jsiReportStore = reportStore.parseDBDataStore(innerRt, reportStoreVectorPtr); + jsi::Array jsiUserStore = + userStore.parseDBDataStore(innerRt, userStoreVectorPtr); auto jsiClientDBStore = jsi::Object(innerRt); jsiClientDBStore.setProperty(innerRt, "messages", jsiMessages); @@ -172,6 +180,7 @@ jsiClientDBStore.setProperty( innerRt, "messageStoreThreads", jsiMessageStoreThreads); jsiClientDBStore.setProperty(innerRt, "reports", jsiReportStore); + jsiClientDBStore.setProperty(innerRt, "users", jsiUserStore); promise->resolve(std::move(jsiClientDBStore)); }); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/UserStore.cpp @@ -16,7 +16,15 @@ jsi::Array UserStore::parseDBDataStore( jsi::Runtime &rt, std::shared_ptr> usersVectorPtr) const { - jsi::Array jsiUsers = jsi::Array(rt, 0); + size_t numUsers = usersVectorPtr->size(); + jsi::Array jsiUsers = jsi::Array(rt, numUsers); + size_t writeIdx = 0; + for (const UserInfo &user : *usersVectorPtr) { + jsi::Object jsiUser = jsi::Object(rt); + jsiUser.setProperty(rt, "id", user.id); + jsiUser.setProperty(rt, "userInfo", user.user_info); + jsiUsers.setValueAtIndex(rt, writeIdx++, jsiUser); + } return jsiUsers; } 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 @@ -73,6 +73,7 @@ threads: [], messageStoreThreads: [], reports: sqliteQueryExecutor.getAllReports(), + users: [], }; }