Page MenuHomePhabricator

D7936.diff
No OneTemporary

D7936.diff

diff --git a/lib/ops/report-store-ops.js b/lib/ops/report-store-ops.js
--- a/lib/ops/report-store-ops.js
+++ b/lib/ops/report-store-ops.js
@@ -23,7 +23,7 @@
export type ClientDBReplaceQueuedReportOperation = {
+type: 'replace_report',
- +payload: { +id: string, +report: string },
+ +payload: ClientDBReport,
};
export type ClientDBReportStoreOperation =
@@ -31,6 +31,8 @@
| RemoveQueuedReportsOperation
| RemoveAllQueuedReportsOperation;
+export type ClientDBReport = { +id: string, +report: string };
+
function processReportStoreOperations(
queuedReports: $ReadOnlyArray<ClientReportCreationRequest>,
reportStoreOps: $ReadOnlyArray<ReportStoreOperation>,
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,7 +16,10 @@
ClientDBThreadStoreOperation,
ThreadStoreOperation,
} from './thread-types.js';
-import type { ReportStoreOperation } from '../ops/report-store-ops.js';
+import type {
+ ReportStoreOperation,
+ ClientDBReport,
+} from '../ops/report-store-ops.js';
export type StoreOperations = {
+draftStoreOperations: $ReadOnlyArray<DraftStoreOperation>,
@@ -36,4 +39,5 @@
+drafts: $ReadOnlyArray<ClientDBDraftInfo>,
+threads: $ReadOnlyArray<ClientDBThreadInfo>,
+messageStoreThreads: $ReadOnlyArray<ClientDBThreadMessageInfo>,
+ +reports: $ReadOnlyArray<ClientDBReport>,
};
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
@@ -290,6 +290,22 @@
return jsiThreads;
}
+jsi::Array parseDBReportStore(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<Report>> reportStoreVectorPtr) {
+ size_t numReports = reportStoreVectorPtr->size();
+ jsi::Array jsiReports = jsi::Array(rt, numReports);
+ size_t writeIdx = 0;
+
+ for (const Report &report : *reportStoreVectorPtr) {
+ jsi::Object jsiReport = jsi::Object(rt);
+ jsiReport.setProperty(rt, "id", report.id);
+ jsiReport.setProperty(rt, "report", report.report);
+ jsiReports.setValueAtIndex(rt, writeIdx++, jsiReport);
+ }
+ return jsiReports;
+}
+
jsi::Value CommCoreModule::getClientDBStore(jsi::Runtime &rt) {
return createPromiseAsJSIValue(
rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
@@ -299,6 +315,7 @@
std::vector<Thread> threadsVector;
std::vector<std::pair<Message, std::vector<Media>>> messagesVector;
std::vector<MessageStoreThread> messageStoreThreadsVector;
+ std::vector<Report> reportStoreVector;
try {
draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts();
messagesVector =
@@ -306,6 +323,8 @@
threadsVector = DatabaseManager::getQueryExecutor().getAllThreads();
messageStoreThreadsVector =
DatabaseManager::getQueryExecutor().getAllMessageStoreThreads();
+ reportStoreVector =
+ DatabaseManager::getQueryExecutor().getAllReports();
} catch (std::system_error &e) {
error = e.what();
}
@@ -319,11 +338,14 @@
auto messageStoreThreadsVectorPtr =
std::make_shared<std::vector<MessageStoreThread>>(
std::move(messageStoreThreadsVector));
+ auto reportStoreVectorPtr = std::make_shared<std::vector<Report>>(
+ std::move(reportStoreVector));
this->jsInvoker_->invokeAsync([&innerRt,
draftsVectorPtr,
messagesVectorPtr,
threadsVectorPtr,
messageStoreThreadsVectorPtr,
+ reportStoreVectorPtr,
error,
promise]() {
if (error.size()) {
@@ -336,6 +358,8 @@
jsi::Array jsiThreads = parseDBThreads(innerRt, threadsVectorPtr);
jsi::Array jsiMessageStoreThreads = parseDBMessageStoreThreads(
innerRt, messageStoreThreadsVectorPtr);
+ jsi::Array jsiReportStore =
+ parseDBReportStore(innerRt, reportStoreVectorPtr);
auto jsiClientDBStore = jsi::Object(innerRt);
jsiClientDBStore.setProperty(innerRt, "messages", jsiMessages);
@@ -343,6 +367,7 @@
jsiClientDBStore.setProperty(innerRt, "drafts", jsiDrafts);
jsiClientDBStore.setProperty(
innerRt, "messageStoreThreads", jsiMessageStoreThreads);
+ jsiClientDBStore.setProperty(innerRt, "reports", jsiReportStore);
promise->resolve(std::move(jsiClientDBStore));
});
diff --git a/web/database/worker/db-worker.js b/web/database/worker/db-worker.js
--- a/web/database/worker/db-worker.js
+++ b/web/database/worker/db-worker.js
@@ -131,6 +131,7 @@
messages: [],
threads: [],
messageStoreThreads: [],
+ reports: [],
};
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 2:06 AM (18 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693169
Default Alt Text
D7936.diff (5 KB)

Event Timeline