Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3406794
D3171.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D3171.id.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -55,6 +55,7 @@
virtual std::vector<OlmPersistSession> getOlmPersistSessionsData() const = 0;
virtual folly::Optional<std::string> getOlmPersistAccountData() const = 0;
virtual void storeOlmPersistData(crypto::Persist persist) const = 0;
+ virtual void setNotifyToken(std::string token) const = 0;
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -48,6 +48,7 @@
std::vector<OlmPersistSession> getOlmPersistSessionsData() const override;
folly::Optional<std::string> getOlmPersistAccountData() const override;
void storeOlmPersistData(crypto::Persist persist) const override;
+ void setNotifyToken(std::string token) const override;
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -733,4 +733,12 @@
}
}
+void SQLiteQueryExecutor::setNotifyToken(std::string token) const {
+ Metadata entry{
+ "notify_token",
+ token,
+ };
+ SQLiteQueryExecutor::getStorage().replace(entry);
+}
+
} // namespace comm
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
@@ -55,6 +55,8 @@
jsi::Object
openSocket(jsi::Runtime &rt, const jsi::String &endpoint) override;
double getCodeVersion(jsi::Runtime &rt) override;
+ jsi::Value
+ setNotifyToken(jsi::Runtime &rt, const jsi::String &token) 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
@@ -904,6 +904,32 @@
double CommCoreModule::getCodeVersion(jsi::Runtime &rt) {
return this->codeVersion;
+}
+
+jsi::Value
+CommCoreModule::setNotifyToken(jsi::Runtime &rt, const jsi::String &token) {
+ auto notifyToken{token.utf8(rt)};
+ return createPromiseAsJSIValue(
+ rt,
+ [this,
+ notifyToken](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ this->databaseThread->scheduleTask([this, notifyToken, promise]() {
+ std::string error;
+ try {
+ DatabaseManager::getQueryExecutor().setNotifyToken(notifyToken);
+ } catch (std::system_error &e) {
+ error = e.what();
+ }
+
+ this->jsInvoker_->invokeAsync([error, promise]() {
+ if (error.size()) {
+ promise->reject(error);
+ } else {
+ promise->resolve(jsi::Value::undefined());
+ }
+ });
+ });
+ });
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/_generated/NativeModules.h b/native/cpp/CommonCpp/_generated/NativeModules.h
--- a/native/cpp/CommonCpp/_generated/NativeModules.h
+++ b/native/cpp/CommonCpp/_generated/NativeModules.h
@@ -36,6 +36,7 @@
virtual jsi::Value getUserOneTimeKeys(jsi::Runtime &rt) = 0;
virtual jsi::Object openSocket(jsi::Runtime &rt, const jsi::String &endpoint) = 0;
virtual double getCodeVersion(jsi::Runtime &rt) = 0;
+virtual jsi::Value setNotifyToken(jsi::Runtime &rt, const jsi::String &token) = 0;
};
diff --git a/native/cpp/CommonCpp/_generated/NativeModules.cpp b/native/cpp/CommonCpp/_generated/NativeModules.cpp
--- a/native/cpp/CommonCpp/_generated/NativeModules.cpp
+++ b/native/cpp/CommonCpp/_generated/NativeModules.cpp
@@ -66,6 +66,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getCodeVersion(rt);
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setNotifyToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->setNotifyToken(rt, args[0].getString(rt));
+}
CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommTurboModule", jsInvoker) {
@@ -87,6 +90,7 @@
methodMap_["getUserOneTimeKeys"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getUserOneTimeKeys};
methodMap_["openSocket"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_openSocket};
methodMap_["getCodeVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion};
+ methodMap_["setNotifyToken"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setNotifyToken};
}
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -46,6 +46,7 @@
+getUserOneTimeKeys: () => Promise<string>;
+openSocket: (endpoint: string) => Object;
+getCodeVersion: () => number;
+ +setNotifyToken: (token: string) => Promise<void>;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 3:27 AM (9 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615388
Default Alt Text
D3171.id.diff (5 KB)
Attached To
Mode
D3171: [CommCoreModule] Introduce `CommCoreModule::setNotifyToken`
Attached
Detach File
Event Timeline
Log In to Comment