Page MenuHomePhabricator

D5647.id18472.diff
No OneTemporary

D5647.id18472.diff

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

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)

Event Timeline