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 @@ -32,9 +32,7 @@ const jsi::String &oldKey, const jsi::String &newKey) override; jsi::Value getClientDBStore(jsi::Runtime &rt) override; - jsi::Value getAllDrafts(jsi::Runtime &rt) override; jsi::Value removeAllDrafts(jsi::Runtime &rt) override; - jsi::Value getAllMessages(jsi::Runtime &rt) override; jsi::Array getAllMessagesSync(jsi::Runtime &rt) override; jsi::Value processDraftStoreOperations( jsi::Runtime &rt, @@ -45,7 +43,6 @@ void processMessageStoreOperationsSync( jsi::Runtime &rt, const jsi::Array &operations) override; - jsi::Value getAllThreads(jsi::Runtime &rt) override; jsi::Array getAllThreadsSync(jsi::Runtime &rt) override; jsi::Value processThreadStoreOperations( jsi::Runtime &rt, 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 @@ -306,34 +306,6 @@ }); } -jsi::Value CommCoreModule::getAllDrafts(jsi::Runtime &rt) { - return createPromiseAsJSIValue( - rt, [=](jsi::Runtime &innerRt, std::shared_ptr promise) { - taskType job = [=, &innerRt]() { - std::string error; - std::vector draftsVector; - try { - draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts(); - } catch (std::system_error &e) { - error = e.what(); - } - auto draftsVectorPtr = - std::make_shared>(std::move(draftsVector)); - this->jsInvoker_->invokeAsync( - [&innerRt, draftsVectorPtr, error, promise]() { - if (error.size()) { - promise->reject(error); - return; - } - jsi::Array jsiDrafts = parseDBDrafts(innerRt, draftsVectorPtr); - promise->resolve(std::move(jsiDrafts)); - }); - }; - GlobalDBSingleton::instance.scheduleOrRunCancellable( - job, promise, this->jsInvoker_); - }); -} - jsi::Value CommCoreModule::removeAllDrafts(jsi::Runtime &rt) { return createPromiseAsJSIValue( rt, [=](jsi::Runtime &innerRt, std::shared_ptr promise) { @@ -369,37 +341,6 @@ return jsiMessages; } -jsi::Value CommCoreModule::getAllMessages(jsi::Runtime &rt) { - return createPromiseAsJSIValue( - rt, [=](jsi::Runtime &innerRt, std::shared_ptr promise) { - taskType job = [=, &innerRt]() { - std::string error; - std::vector>> messagesVector; - try { - messagesVector = - DatabaseManager::getQueryExecutor().getAllMessages(); - } catch (std::system_error &e) { - error = e.what(); - } - auto messagesVectorPtr = std::make_shared< - std::vector>>>( - std::move(messagesVector)); - this->jsInvoker_->invokeAsync( - [messagesVectorPtr, &innerRt, promise, error]() { - if (error.size()) { - promise->reject(error); - return; - } - jsi::Array jsiMessages = - parseDBMessages(innerRt, messagesVectorPtr); - promise->resolve(std::move(jsiMessages)); - }); - }; - GlobalDBSingleton::instance.scheduleOrRunCancellable( - job, promise, this->jsInvoker_); - }); -} - const std::string UPDATE_DRAFT_OPERATION = "update"; const std::string MOVE_DRAFT_OPERATION = "move"; const std::string REMOVE_ALL_DRAFTS_OPERATION = "remove_all"; @@ -594,34 +535,6 @@ }); } -jsi::Value CommCoreModule::getAllThreads(jsi::Runtime &rt) { - return createPromiseAsJSIValue( - rt, [=](jsi::Runtime &innerRt, std::shared_ptr promise) { - taskType job = [=, &innerRt]() { - std::string error; - std::vector threadsVector; - try { - threadsVector = DatabaseManager::getQueryExecutor().getAllThreads(); - } catch (std::system_error &e) { - error = e.what(); - } - auto threadsVectorPtr = - std::make_shared>(std::move(threadsVector)); - this->jsInvoker_->invokeAsync([=, &innerRt]() { - if (error.size()) { - promise->reject(error); - return; - } - - jsi::Array jsiThreads = parseDBThreads(innerRt, threadsVectorPtr); - promise->resolve(std::move(jsiThreads)); - }); - }; - GlobalDBSingleton::instance.scheduleOrRunCancellable( - job, promise, this->jsInvoker_); - }); -}; - jsi::Array CommCoreModule::getAllThreadsSync(jsi::Runtime &rt) { auto threadsVector = this->runSyncOrThrowJSError>( rt, []() { return DatabaseManager::getQueryExecutor().getAllThreads(); }); 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 @@ -22,14 +22,11 @@ virtual jsi::Value updateDraft(jsi::Runtime &rt, const jsi::String &key, const jsi::String &text) = 0; virtual jsi::Value moveDraft(jsi::Runtime &rt, const jsi::String &oldKey, const jsi::String &newKey) = 0; virtual jsi::Value getClientDBStore(jsi::Runtime &rt) = 0; -virtual jsi::Value getAllDrafts(jsi::Runtime &rt) = 0; virtual jsi::Value removeAllDrafts(jsi::Runtime &rt) = 0; -virtual jsi::Value getAllMessages(jsi::Runtime &rt) = 0; virtual jsi::Array getAllMessagesSync(jsi::Runtime &rt) = 0; virtual jsi::Value processDraftStoreOperations(jsi::Runtime &rt, const jsi::Array &operations) = 0; virtual jsi::Value processMessageStoreOperations(jsi::Runtime &rt, const jsi::Array &operations) = 0; virtual void processMessageStoreOperationsSync(jsi::Runtime &rt, const jsi::Array &operations) = 0; -virtual jsi::Value getAllThreads(jsi::Runtime &rt) = 0; virtual jsi::Array getAllThreadsSync(jsi::Runtime &rt) = 0; virtual jsi::Value processThreadStoreOperations(jsi::Runtime &rt, const jsi::Array &operations) = 0; virtual void processThreadStoreOperationsSync(jsi::Runtime &rt, const jsi::Array &operations) = 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 @@ -24,15 +24,9 @@ static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getClientDBStore(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getClientDBStore(rt); } -static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllDrafts(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getAllDrafts(rt); -} static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeAllDrafts(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->removeAllDrafts(rt); } -static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getAllMessages(rt); -} static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllMessagesSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getAllMessagesSync(rt); } @@ -46,9 +40,6 @@ static_cast(&turboModule)->processMessageStoreOperationsSync(rt, args[0].getObject(rt).getArray(rt)); return jsi::Value::undefined(); } -static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllThreads(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getAllThreads(rt); -} static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllThreadsSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getAllThreadsSync(rt); } @@ -99,14 +90,11 @@ methodMap_["updateDraft"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_updateDraft}; methodMap_["moveDraft"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_moveDraft}; methodMap_["getClientDBStore"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getClientDBStore}; - methodMap_["getAllDrafts"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllDrafts}; methodMap_["removeAllDrafts"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeAllDrafts}; - methodMap_["getAllMessages"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllMessages}; methodMap_["getAllMessagesSync"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllMessagesSync}; methodMap_["processDraftStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processDraftStoreOperations}; methodMap_["processMessageStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processMessageStoreOperations}; methodMap_["processMessageStoreOperationsSync"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processMessageStoreOperationsSync}; - methodMap_["getAllThreads"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllThreads}; methodMap_["getAllThreadsSync"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllThreadsSync}; methodMap_["processThreadStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processThreadStoreOperations}; methodMap_["processThreadStoreOperationsSync"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processThreadStoreOperationsSync}; diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js --- a/native/schema/CommCoreModuleSchema.js +++ b/native/schema/CommCoreModuleSchema.js @@ -29,9 +29,7 @@ +updateDraft: (key: string, text: string) => Promise; +moveDraft: (oldKey: string, newKey: string) => Promise; +getClientDBStore: () => Promise; - +getAllDrafts: () => Promise<$ReadOnlyArray>; +removeAllDrafts: () => Promise; - +getAllMessages: () => Promise<$ReadOnlyArray>; +getAllMessagesSync: () => $ReadOnlyArray; +processDraftStoreOperations: ( operations: $ReadOnlyArray, @@ -42,7 +40,6 @@ +processMessageStoreOperationsSync: ( operations: $ReadOnlyArray, ) => void; - +getAllThreads: () => Promise<$ReadOnlyArray>; +getAllThreadsSync: () => $ReadOnlyArray; +processThreadStoreOperations: ( operations: $ReadOnlyArray,