Page MenuHomePhabricator

D12782.diff
No OneTemporary

D12782.diff

diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -230,6 +230,11 @@
jsi::String deviceID) override;
virtual jsi::Value getSyncedDatabaseVersion(jsi::Runtime &rt) override;
virtual jsi::Value markPrekeysAsPublished(jsi::Runtime &rt) override;
+ virtual jsi::Value insertMessagesForSearch(
+ jsi::Runtime &rt,
+ jsi::String originalMessageID,
+ jsi::String messageID,
+ jsi::String content) override;
public:
CommCoreModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
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
@@ -76,6 +76,39 @@
});
}
+jsi::Value CommCoreModule::insertMessagesForSearch(
+ jsi::Runtime &rt,
+ jsi::String originalMessageID,
+ jsi::String messageID,
+ jsi::String content) {
+
+ std::string originalMessageIDStr = originalMessageID.utf8(rt);
+ std::string messageIDStr = messageID.utf8(rt);
+ std::string contentStr = content.utf8(rt);
+
+ return createPromiseAsJSIValue(
+ rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ taskType job = [=]() {
+ std::string error;
+ try {
+ DatabaseManager::getQueryExecutor().updateMessageSearchResult(
+ originalMessageIDStr, messageIDStr, contentStr);
+ } catch (std::system_error &e) {
+ error = e.what();
+ }
+ this->jsInvoker_->invokeAsync([=]() {
+ if (error.size()) {
+ promise->reject(error);
+ } else {
+ promise->resolve(true);
+ }
+ });
+ };
+ GlobalDBSingleton::instance.scheduleOrRunCancellable(
+ job, promise, this->jsInvoker_);
+ });
+}
+
jsi::Value CommCoreModule::moveDraft(
jsi::Runtime &rt,
jsi::String oldKey,
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -208,6 +208,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_markPrekeysAsPublished(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->markPrekeysAsPublished(rt);
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_insertMessagesForSearch(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->insertMessagesForSearch(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
+}
CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommTurboModule", jsInvoker) {
@@ -274,6 +277,7 @@
methodMap_["removeOutboundP2PMessagesOlderThan"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeOutboundP2PMessagesOlderThan};
methodMap_["getSyncedDatabaseVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSyncedDatabaseVersion};
methodMap_["markPrekeysAsPublished"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_markPrekeysAsPublished};
+ methodMap_["insertMessagesForSearch"] = MethodMetadata {3, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_insertMessagesForSearch};
}
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -83,6 +83,7 @@
virtual jsi::Value removeOutboundP2PMessagesOlderThan(jsi::Runtime &rt, jsi::String messageID, jsi::String deviceID) = 0;
virtual jsi::Value getSyncedDatabaseVersion(jsi::Runtime &rt) = 0;
virtual jsi::Value markPrekeysAsPublished(jsi::Runtime &rt) = 0;
+ virtual jsi::Value insertMessagesForSearch(jsi::Runtime &rt, jsi::String originalMessageID, jsi::String messageID, jsi::String content) = 0;
};
@@ -608,6 +609,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::markPrekeysAsPublished, jsInvoker_, instance_);
}
+ jsi::Value insertMessagesForSearch(jsi::Runtime &rt, jsi::String originalMessageID, jsi::String messageID, jsi::String content) override {
+ static_assert(
+ bridging::getParameterCount(&T::insertMessagesForSearch) == 4,
+ "Expected insertMessagesForSearch(...) to have 4 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::insertMessagesForSearch, jsInvoker_, instance_, std::move(originalMessageID), std::move(messageID), std::move(content));
+ }
private:
T *instance_;
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -165,6 +165,11 @@
) => Promise<void>;
+getSyncedDatabaseVersion: () => Promise<string>;
+markPrekeysAsPublished: () => Promise<void>;
+ +insertMessagesForSearch: (
+ originalMessageID: string,
+ messageID: string,
+ content: string,
+ ) => Promise<boolean>;
}
export interface CoreModuleSpec extends Spec {

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 2:50 AM (20 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578094
Default Alt Text
D12782.diff (5 KB)

Event Timeline