diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js --- a/lib/types/thread-types.js +++ b/lib/types/thread-types.js @@ -228,6 +228,7 @@ +sourceMessageID?: string, +repliesCount: number, +pinnedCount?: number, + +timestamps?: ?string, }; export type ThreadDeletionRequest = { 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 @@ -805,6 +805,28 @@ return create_table(db, query, "inbound_p2p_messages"); } +bool add_timestamps_column_to_threads_table(sqlite3 *db) { + char *error; + sqlite3_exec( + db, + "ALTER TABLE threads" + " ADD COLUMN timestamps TEXT;", + nullptr, + nullptr, + &error); + + if (!error) { + return true; + } + + std::ostringstream stringStream; + stringStream << "Error updating threads table: " << error; + Logger::log(stringStream.str()); + + sqlite3_free(error); + return false; +} + bool create_schema(sqlite3 *db) { char *error; int sidebarSourceTypeInt = static_cast(MessageType::SIDEBAR_SOURCE); @@ -877,7 +899,8 @@ " source_message_id TEXT," " replies_count INTEGER NOT NULL," " avatar TEXT," - " pinned_count INTEGER NOT NULL DEFAULT 0" + " pinned_count INTEGER NOT NULL DEFAULT 0," + " timestamps TEXT" ");" "CREATE TABLE IF NOT EXISTS metadata (" @@ -1240,7 +1263,8 @@ {49, {add_supports_auto_retry_column_to_p2p_messages_table, true}}, {50, {create_message_search_table, true}}, {51, {update_messages_idx_target_message_type_time, true}}, - {52, {recreate_inbound_p2p_messages_table, true}}}}; + {52, {recreate_inbound_p2p_messages_table, true}}, + {53, {add_timestamps_column_to_threads_table, true}}}}; enum class MigrationResult { SUCCESS, FAILURE, NOT_APPLIED }; @@ -1826,8 +1850,8 @@ "REPLACE INTO threads (" " id, type, name, description, color, creation_time, parent_thread_id," " containing_thread_id, community, members, roles, current_user," - " source_message_id, replies_count, avatar, pinned_count) " - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; + " source_message_id, replies_count, avatar, pinned_count, timestamps) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; replaceEntity( SQLiteQueryExecutor::getConnection(), replaceThreadSQL, thread); diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h b/native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h --- a/native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h +++ b/native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h @@ -26,6 +26,7 @@ int replies_count; std::unique_ptr avatar; int pinned_count; + std::unique_ptr timestamps; static Thread fromSQLResult(sqlite3_stmt *sqlRow, int idx) { return Thread{ @@ -45,6 +46,7 @@ getIntFromSQLRow(sqlRow, idx + 13), getStringPtrFromSQLRow(sqlRow, idx + 14), getIntFromSQLRow(sqlRow, idx + 15), + getStringPtrFromSQLRow(sqlRow, idx + 16), }; } @@ -64,7 +66,8 @@ bindStringPtrToSQL(source_message_id, sql, idx + 12); bindIntToSQL(replies_count, sql, idx + 13); bindStringPtrToSQL(avatar, sql, idx + 14); - return bindIntToSQL(pinned_count, sql, idx + 15); + bindIntToSQL(pinned_count, sql, idx + 15); + return bindStringPtrToSQL(timestamps, sql, idx + 16); } }; @@ -85,6 +88,7 @@ int replies_count; NullableString avatar; int pinned_count; + NullableString timestamps; WebThread() = default; @@ -105,6 +109,7 @@ replies_count = thread.replies_count; avatar = NullableString(thread.avatar); pinned_count = thread.pinned_count; + timestamps = NullableString(thread.timestamps); } Thread toThread() const { @@ -125,6 +130,7 @@ thread.replies_count = replies_count; thread.avatar = avatar.resetValue(); thread.pinned_count = pinned_count; + thread.timestamps = timestamps.resetValue(); return thread; } }; diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadStore.cpp @@ -73,6 +73,11 @@ jsiThread.setProperty(rt, "avatar", avatar); } + if (thread.timestamps) { + auto timestamps = jsi::String::createFromUtf8(rt, *thread.timestamps); + jsiThread.setProperty(rt, "timestamps", timestamps); + } + jsiThreads.setValueAtIndex(rt, writeIdx++, jsiThread); } return jsiThreads; @@ -169,6 +174,11 @@ int pinnedCount = maybePinnedCount.isNumber() ? std::lround(maybePinnedCount.asNumber()) : 0; + + jsi::Value maybeTimestamps = threadObj.getProperty(rt, "timestamps"); + std::unique_ptr timestamps = maybeTimestamps.isString() + ? std::make_unique(maybeTimestamps.asString(rt).utf8(rt)) + : nullptr; Thread thread{ threadID, type, @@ -185,7 +195,8 @@ std::move(sourceMessageID), repliesCount, std::move(avatar), - pinnedCount}; + pinnedCount, + std::move(timestamps)}; threadStoreOps.push_back( std::make_unique(std::move(thread))); diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp --- a/web/cpp/SQLiteQueryExecutorBindings.cpp +++ b/web/cpp/SQLiteQueryExecutorBindings.cpp @@ -92,7 +92,8 @@ .field("sourceMessageID", &WebThread::source_message_id) .field("repliesCount", &WebThread::replies_count) .field("avatar", &WebThread::avatar) - .field("pinnedCount", &WebThread::pinned_count); + .field("pinnedCount", &WebThread::pinned_count) + .field("timestamps", &WebThread::timestamps); value_object("WebMessage") .field("id", &WebMessage::id) diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@