Page MenuHomePhabricator

D12739.id42370.diff
No OneTemporary

D12739.id42370.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
@@ -231,6 +231,8 @@
jsi::String deviceID) override;
virtual jsi::Value getSyncedDatabaseVersion(jsi::Runtime &rt) override;
virtual jsi::Value markPrekeysAsPublished(jsi::Runtime &rt) override;
+ virtual jsi::Value
+ getRelatedMessages(jsi::Runtime &rt, jsi::String messageID) 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
@@ -2593,4 +2593,40 @@
});
}
+jsi::Value
+CommCoreModule::getRelatedMessages(jsi::Runtime &rt, jsi::String messageID) {
+ std::string messageIDStr = messageID.utf8(rt);
+ return createPromiseAsJSIValue(
+ rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ taskType job = [=, &innerRt]() {
+ std::string error;
+ std::shared_ptr<std::vector<MessageEntity>> messages;
+ try {
+ messages = std::make_shared<std::vector<MessageEntity>>(
+ DatabaseManager::getQueryExecutor().getRelatedMessages(
+ messageIDStr));
+ } catch (std::system_error &e) {
+ error = e.what();
+ }
+
+ this->jsInvoker_->invokeAsync([&innerRt,
+ error,
+ promise,
+ messages,
+ messageStore = this->messageStore]() {
+ if (error.size()) {
+ promise->reject(error);
+ return;
+ }
+
+ jsi::Array jsiMessages =
+ messageStore.parseDBDataStore(innerRt, messages);
+ promise->resolve(std::move(jsiMessages));
+ });
+ };
+ GlobalDBSingleton::instance.scheduleOrRunCancellable(
+ job, promise, this->jsInvoker_);
+ });
+}
+
} // namespace comm
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_getRelatedMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getRelatedMessages(rt, args[0].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_["getRelatedMessages"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getRelatedMessages};
}
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 getRelatedMessages(jsi::Runtime &rt, jsi::String messageID) = 0;
};
@@ -608,6 +609,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::markPrekeysAsPublished, jsInvoker_, instance_);
}
+ jsi::Value getRelatedMessages(jsi::Runtime &rt, jsi::String messageID) override {
+ static_assert(
+ bridging::getParameterCount(&T::getRelatedMessages) == 2,
+ "Expected getRelatedMessages(...) to have 2 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::getRelatedMessages, jsInvoker_, instance_, std::move(messageID));
+ }
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,7 @@
) => Promise<void>;
+getSyncedDatabaseVersion: () => Promise<string>;
+markPrekeysAsPublished: () => Promise<void>;
+ +getRelatedMessages: (messageID: string) => Promise<ClientDBMessageInfo[]>;
}
export interface CoreModuleSpec extends Spec {

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 7:23 AM (18 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2450017
Default Alt Text
D12739.id42370.diff (5 KB)

Event Timeline