Page MenuHomePhabricator

D13211.diff
No OneTemporary

D13211.diff

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<int>(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<Thread>(
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<std::string> avatar;
int pinned_count;
+ std::unique_ptr<std::string> 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<std::string> timestamps = maybeTimestamps.isString()
+ ? std::make_unique<std::string>(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<ReplaceThreadOperation>(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>("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$@<O00001
literal 0
Hc$@<O00001
diff --git a/web/shared-worker/queries/messages-and-media-queries.test.js b/web/shared-worker/queries/messages-and-media-queries.test.js
--- a/web/shared-worker/queries/messages-and-media-queries.test.js
+++ b/web/shared-worker/queries/messages-and-media-queries.test.js
@@ -103,6 +103,7 @@
sourceMessageID: createNullableString(),
repliesCount: 0,
pinnedCount: 0,
+ timestamps: createNullableString(),
});
queryExecutor.replaceThreadWeb({
id: '2',
@@ -121,6 +122,7 @@
sourceMessageID: createNullableString(),
repliesCount: 0,
pinnedCount: 0,
+ timestamps: createNullableString(),
});
});
diff --git a/web/shared-worker/queries/threads-queries.test.js b/web/shared-worker/queries/threads-queries.test.js
--- a/web/shared-worker/queries/threads-queries.test.js
+++ b/web/shared-worker/queries/threads-queries.test.js
@@ -1,6 +1,7 @@
// @flow
import { getDatabaseModule } from '../db-module.js';
+import { createNullableString } from '../types/entities.js';
import { clearSensitiveData } from '../utils/db-utils.js';
const FILE_PATH = 'test.sqlite';
@@ -24,56 +25,59 @@
queryExecutor.replaceThreadWeb({
id: '1',
type: 1,
- name: { value: '', isNull: true },
- avatar: { value: '', isNull: true },
- description: { value: '', isNull: true },
+ name: createNullableString(),
+ avatar: createNullableString(),
+ description: createNullableString(),
color: '1',
creationTime: '1',
- parentThreadID: { value: '', isNull: true },
- containingThreadID: { value: '', isNull: true },
- community: { value: '', isNull: true },
+ parentThreadID: createNullableString(),
+ containingThreadID: createNullableString(),
+ community: createNullableString(),
members: '1',
roles: '1',
currentUser: '1',
- sourceMessageID: { value: '', isNull: true },
+ sourceMessageID: createNullableString(),
repliesCount: 1,
pinnedCount: 1,
+ timestamps: createNullableString(),
});
queryExecutor.replaceThreadWeb({
id: '2',
type: 1,
- name: { value: '', isNull: true },
- avatar: { value: '', isNull: true },
- description: { value: '', isNull: true },
+ name: createNullableString(),
+ avatar: createNullableString(),
+ description: createNullableString(),
color: '1',
creationTime: '1',
- parentThreadID: { value: '', isNull: true },
- containingThreadID: { value: '', isNull: true },
- community: { value: '', isNull: true },
+ parentThreadID: createNullableString(),
+ containingThreadID: createNullableString(),
+ community: createNullableString(),
members: '1',
roles: '1',
currentUser: '1',
- sourceMessageID: { value: '', isNull: true },
+ sourceMessageID: createNullableString(),
repliesCount: 1,
pinnedCount: 1,
+ timestamps: createNullableString(),
});
queryExecutor.replaceThreadWeb({
id: '3',
type: 1,
- name: { value: '', isNull: true },
- avatar: { value: '', isNull: true },
- description: { value: '', isNull: true },
+ name: createNullableString(),
+ avatar: createNullableString(),
+ description: createNullableString(),
color: '1',
creationTime: '1',
- parentThreadID: { value: '', isNull: true },
- containingThreadID: { value: '', isNull: true },
- community: { value: '', isNull: true },
+ parentThreadID: createNullableString(),
+ containingThreadID: createNullableString(),
+ community: createNullableString(),
members: '1',
roles: '1',
currentUser: '1',
- sourceMessageID: { value: '', isNull: true },
+ sourceMessageID: createNullableString(),
repliesCount: 1,
pinnedCount: 1,
+ timestamps: createNullableString(),
});
});
diff --git a/web/shared-worker/types/entities.js b/web/shared-worker/types/entities.js
--- a/web/shared-worker/types/entities.js
+++ b/web/shared-worker/types/entities.js
@@ -31,6 +31,7 @@
+sourceMessageID: NullableString,
+repliesCount: number,
+pinnedCount: number,
+ +timestamps: NullableString,
};
function createNullableString(value: ?string): NullableString {
@@ -79,6 +80,7 @@
sourceMessageID: createNullableString(info.sourceMessageID),
repliesCount: info.repliesCount,
pinnedCount: info.pinnedCount || 0,
+ timestamps: createNullableString(info.timestamps),
};
}
@@ -105,6 +107,7 @@
currentUser: thread.currentUser,
repliesCount: thread.repliesCount,
pinnedCount: thread.pinnedCount,
+ timestamps: thread.timestamps.isNull ? null : thread.timestamps.value,
};
if (!thread.sourceMessageID.isNull) {
result = {
diff --git a/web/shared-worker/types/entities.test.js b/web/shared-worker/types/entities.test.js
--- a/web/shared-worker/types/entities.test.js
+++ b/web/shared-worker/types/entities.test.js
@@ -26,6 +26,7 @@
community: '1',
avatar: null,
pinnedCount: 0,
+ timestamps: null,
};
const clientDBThreadInfoWithAvatar: ClientDBThreadInfo = {

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 4:32 PM (19 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2444584
Default Alt Text
D13211.diff (11 KB)

Event Timeline