Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3406265
D3172.id9623.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
D3172.id9623.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
@@ -56,6 +56,7 @@
virtual folly::Optional<std::string> getOlmPersistAccountData() const = 0;
virtual void storeOlmPersistData(crypto::Persist persist) const = 0;
virtual void setNotifyToken(std::string token) const = 0;
+ virtual void clearNotifyToken() 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
@@ -49,6 +49,7 @@
folly::Optional<std::string> getOlmPersistAccountData() const override;
void storeOlmPersistData(crypto::Persist persist) const override;
void setNotifyToken(std::string token) const override;
+ void clearNotifyToken() 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
@@ -741,4 +741,8 @@
SQLiteQueryExecutor::getStorage().replace(entry);
}
+void SQLiteQueryExecutor::clearNotifyToken() const {
+ SQLiteQueryExecutor::getStorage().remove<Metadata>("notify_token");
+}
+
} // 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
@@ -57,6 +57,7 @@
double getCodeVersion(jsi::Runtime &rt) override;
jsi::Value
setNotifyToken(jsi::Runtime &rt, const jsi::String &token) override;
+ jsi::Value clearNotifyToken(jsi::Runtime &rt) 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
@@ -921,6 +921,27 @@
error = e.what();
}
+ this->jsInvoker_->invokeAsync([error, promise]() {
+ if (error.size()) {
+ promise->reject(error);
+ } else {
+ promise->resolve(jsi::Value::undefined());
+ }
+ });
+ });
+ });
+}
+
+jsi::Value CommCoreModule::clearNotifyToken(jsi::Runtime &rt) {
+ return createPromiseAsJSIValue(
+ rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ this->databaseThread->scheduleTask([this, promise]() {
+ std::string error;
+ try {
+ DatabaseManager::getQueryExecutor().clearNotifyToken();
+ } catch (std::system_error &e) {
+ error = e.what();
+ }
this->jsInvoker_->invokeAsync([error, promise]() {
if (error.size()) {
promise->reject(error);
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
@@ -37,6 +37,7 @@
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;
+virtual jsi::Value clearNotifyToken(jsi::Runtime &rt) = 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
@@ -69,6 +69,9 @@
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));
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearNotifyToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->clearNotifyToken(rt);
+}
CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule("CommTurboModule", jsInvoker) {
@@ -91,6 +94,7 @@
methodMap_["openSocket"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_openSocket};
methodMap_["getCodeVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion};
methodMap_["setNotifyToken"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setNotifyToken};
+ methodMap_["clearNotifyToken"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearNotifyToken};
}
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -47,6 +47,7 @@
+openSocket: (endpoint: string) => Object;
+getCodeVersion: () => number;
+setNotifyToken: (token: string) => Promise<void>;
+ +clearNotifyToken: () => Promise<void>;
}
export default (TurboModuleRegistry.getEnforcing<Spec>(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 5, 1:16 AM (13 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2614222
Default Alt Text
D3172.id9623.diff (5 KB)
Attached To
Mode
D3172: [CommCoreModule] Introduce `CommCoreModule::clearNotifyToken`
Attached
Detach File
Event Timeline
Log In to Comment