Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3380102
D4235.id13589.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D4235.id13589.diff
View Options
diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt
--- a/native/android/app/CMakeLists.txt
+++ b/native/android/app/CMakeLists.txt
@@ -72,6 +72,8 @@
# comm native mutual code
../../cpp/CommonCpp/NativeModules
../../cpp/CommonCpp/NativeModules/InternalModules
+ ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities
+ ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities
../../cpp/CommonCpp/DatabaseManagers
../../cpp/CommonCpp/Tools
../../cpp/CommonCpp/grpc/_generated
@@ -80,8 +82,7 @@
# search for all cpp files in this directory
file(GLOB SQLCIPHER "../../node_modules/@commapp/sqlcipher-amalgamation/src/*.c")
-file(GLOB COMMON_NATIVE_CODE "../../cpp/CommonCpp/**/*.cpp")
-file(GLOB COMMON_NATIVE_INTERNAL "../../cpp/CommonCpp/**/**/*.cpp")
+file(GLOB_RECURSE COMMON_NATIVE_CODE "../../cpp/CommonCpp/**/*.cpp")
file(GLOB ANDROID_NATIVE_CODE "./src/cpp/*.cpp")
file(GLOB DOUBLE_CONVERSION_SOURCES "./build/third-party-ndk/double-conversion/double-conversion/*.cc")
file(GLOB GRPC_CODE "../../cpp/CommonCpp/grpc/_generated/*.cc")
@@ -121,6 +122,10 @@
./build/third-party-ndk/folly/folly/String.cpp
./build/third-party-ndk/folly/folly/portability/SysUio.cpp
./build/third-party-ndk/folly/folly/net/NetOps.cpp
+ ./build/third-party-ndk/folly/folly/dynamic.cpp
+ ./build/third-party-ndk/folly/folly/json.cpp
+ ./build/third-party-ndk/folly/folly/json_pointer.cpp
+ ./build/third-party-ndk/folly/folly/Unicode.cpp
# double-conversion
${DOUBLE_CONVERSION_SOURCES}
@@ -130,7 +135,6 @@
# comm code
${ANDROID_NATIVE_CODE}
${COMMON_NATIVE_CODE}
- ${COMMON_NATIVE_INTERNAL}
)
add_definitions(
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "../../../DatabaseManagers/entities/Thread.h"
+
+#include <string>
+
+namespace comm {
+class ThreadOperations {
+public:
+ static void updateSQLiteUnreadStatus(std::string &threadID, bool unread);
+};
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp
@@ -0,0 +1,39 @@
+#include "ThreadOperations.h"
+#include "../../../DatabaseManagers/DatabaseManager.h"
+#include "Logger.h"
+#include <folly/String.h>
+#include <folly/json.h>
+#include <stdexcept>
+
+namespace comm {
+void ThreadOperations::updateSQLiteUnreadStatus(
+ std::string &threadID,
+ bool unread) {
+ std::unique_ptr<Thread> thread =
+ DatabaseManager::getQueryExecutor().getThread(threadID);
+ if (thread == nullptr) {
+ throw std::runtime_error(
+ "Attempted to update non-existing thread with ID: " + threadID);
+ }
+ folly::dynamic updatedCurrentUser;
+ try {
+ updatedCurrentUser = folly::parseJson(thread->current_user);
+ } catch (const folly::json::parse_error &e) {
+ Logger::log(
+ "Invalid json structure of current_user field of thread of id: " +
+ threadID + ". Details: " + std::string(e.what()));
+ return;
+ }
+ updatedCurrentUser["unread"] = unread;
+ try {
+ thread->current_user = folly::toJson(updatedCurrentUser);
+ } catch (const folly::json::parse_error &e) {
+ Logger::log(
+ "Failed to serialize updated current_user JSON object. Details: " +
+ std::string(e.what()));
+ return;
+ }
+
+ DatabaseManager::getQueryExecutor().replaceThread(*thread);
+}
+} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 9:05 PM (21 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594913
Default Alt Text
D4235.id13589.diff (3 KB)
Attached To
Mode
D4235: Implement C++ code to update thread unread status
Attached
Detach File
Event Timeline
Log In to Comment