Page MenuHomePhabricator

D9911.diff
No OneTemporary

D9911.diff

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<DraftStoreOperation>,
@@ -46,4 +49,5 @@
+threads: $ReadOnlyArray<ClientDBThreadInfo>,
+messageStoreThreads: $ReadOnlyArray<ClientDBThreadMessageInfo>,
+reports: $ReadOnlyArray<ClientDBReport>,
+ +users: $ReadOnlyArray<ClientDBUserInfo>,
};
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<std::pair<Message, std::vector<Media>>> messagesVector;
std::vector<MessageStoreThread> messageStoreThreadsVector;
std::vector<Report> reportStoreVector;
+ std::vector<UserInfo> 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::vector<Report>>(
std::move(reportStoreVector));
+ auto userStoreVectorPtr = std::make_shared<std::vector<UserInfo>>(
+ 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<std::vector<UserInfo>> 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: [],
};
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 8, 12:00 PM (2 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2817253
Default Alt Text
D9911.diff (5 KB)

Event Timeline