Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3393637
D5647.id18472.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5647.id18472.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
@@ -0,0 +1,40 @@
+#pragma once
+
+namespace comm {
+class DraftStoreOperationBase {
+public:
+ virtual void execute() = 0;
+ virtual ~DraftStoreOperationBase(){};
+};
+
+class UpdateDraftOperation : public DraftStoreOperationBase {
+public:
+ UpdateDraftOperation(jsi::Runtime &rt, const jsi::Object &payload)
+ : key{payload.getProperty(rt, "key").asString(rt).utf8(rt)},
+ text{payload.getProperty(rt, "text").asString(rt).utf8(rt)} {
+ }
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().updateDraft(this->key, this->text);
+ }
+
+private:
+ std::string key;
+ std::string text;
+};
+
+class MoveDraftOperation : public DraftStoreOperationBase {
+public:
+ MoveDraftOperation(jsi::Runtime &rt, const jsi::Object &payload)
+ : oldKey{payload.getProperty(rt, "oldKey").asString(rt).utf8(rt)},
+ newKey{payload.getProperty(rt, "newKey").asString(rt).utf8(rt)} {
+ }
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().moveDraft(this->oldKey, this->newKey);
+ }
+
+private:
+ std::string oldKey;
+ std::string newKey;
+};
+
+} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 3:15 PM (15 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605328
Default Alt Text
D5647.id18472.diff (1 KB)
Attached To
Mode
D5647: Implement DraftStoreOperations C++ utility
Attached
Detach File
Event Timeline
Log In to Comment