Page MenuHomePhabricator

D11153.id37670.diff
No OneTemporary

D11153.id37670.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
@@ -13,6 +13,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 { ClientDBCommunityInfo } from '../ops/community-store-ops.js';
import type {
ClientDBKeyserverInfo,
ClientDBKeyserverStoreOperation,
@@ -61,6 +62,7 @@
+reports: $ReadOnlyArray<ClientDBReport>,
+users: $ReadOnlyArray<ClientDBUserInfo>,
+keyservers: $ReadOnlyArray<ClientDBKeyserverInfo>,
+ +communities: $ReadOnlyArray<ClientDBCommunityInfo>,
};
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
@@ -118,6 +118,7 @@
std::vector<Report> reportStoreVector;
std::vector<UserInfo> userStoreVector;
std::vector<KeyserverInfo> keyserverStoreVector;
+ std::vector<CommunityInfo> communityStoreVector;
try {
draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts();
messagesVector =
@@ -130,6 +131,8 @@
userStoreVector = DatabaseManager::getQueryExecutor().getAllUsers();
keyserverStoreVector =
DatabaseManager::getQueryExecutor().getAllKeyservers();
+ communityStoreVector =
+ DatabaseManager::getQueryExecutor().getAllCommunities();
} catch (std::system_error &e) {
error = e.what();
}
@@ -150,6 +153,9 @@
auto keyserveStoreVectorPtr =
std::make_shared<std::vector<KeyserverInfo>>(
std::move(keyserverStoreVector));
+ auto communityStoreVectorPtr =
+ std::make_shared<std::vector<CommunityInfo>>(
+ std::move(communityStoreVector));
this->jsInvoker_->invokeAsync([&innerRt,
draftsVectorPtr,
messagesVectorPtr,
@@ -158,6 +164,7 @@
reportStoreVectorPtr,
userStoreVectorPtr,
keyserveStoreVectorPtr,
+ communityStoreVectorPtr,
error,
promise,
draftStore = this->draftStore,
@@ -165,8 +172,9 @@
messageStore = this->messageStore,
reportStore = this->reportStore,
userStore = this->userStore,
- keyserverStore =
- this->keyserverStore]() {
+ keyserverStore = this->keyserverStore,
+ communityStore =
+ this->communityStore]() {
if (error.size()) {
promise->reject(error);
return;
@@ -186,6 +194,8 @@
userStore.parseDBDataStore(innerRt, userStoreVectorPtr);
jsi::Array jsiKeyserverStore = keyserverStore.parseDBDataStore(
innerRt, keyserveStoreVectorPtr);
+ jsi::Array jsiCommunityStore = communityStore.parseDBDataStore(
+ innerRt, communityStoreVectorPtr);
auto jsiClientDBStore = jsi::Object(innerRt);
jsiClientDBStore.setProperty(innerRt, "messages", jsiMessages);
@@ -197,6 +207,8 @@
jsiClientDBStore.setProperty(innerRt, "users", jsiUserStore);
jsiClientDBStore.setProperty(
innerRt, "keyservers", jsiKeyserverStore);
+ jsiClientDBStore.setProperty(
+ innerRt, "communities", jsiCommunityStore);
promise->resolve(std::move(jsiClientDBStore));
});
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/CommunityStore.cpp
@@ -17,7 +17,15 @@
jsi::Array CommunityStore::parseDBDataStore(
jsi::Runtime &rt,
std::shared_ptr<std::vector<CommunityInfo>> communitiesVectorPtr) const {
- jsi::Array jsiCommunities = jsi::Array(rt, 0);
+ size_t numCommunities = communitiesVectorPtr->size();
+ jsi::Array jsiCommunities = jsi::Array(rt, numCommunities);
+ size_t writeIdx = 0;
+ for (const CommunityInfo &community : *communitiesVectorPtr) {
+ jsi::Object jsiCommunity = jsi::Object(rt);
+ jsiCommunity.setProperty(rt, "id", community.id);
+ jsiCommunity.setProperty(rt, "communityInfo", community.community_info);
+ jsiCommunities.setValueAtIndex(rt, writeIdx++, jsiCommunity);
+ }
return jsiCommunities;
}
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
@@ -217,6 +217,7 @@
reports: sqliteQueryExecutor.getAllReports(),
users: [],
keyservers: sqliteQueryExecutor.getAllKeyservers(),
+ communities: [],
};
}

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 1:47 AM (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592115
Default Alt Text
D11153.id37670.diff (5 KB)

Event Timeline