Fix group metadata sync setting epoch timestamp for new groups (#15)

updateChatName() was inserting new groups with last_message_time set to
Unix epoch (1970-01-01), causing newly discovered groups to appear at
the bottom of activity-ordered listings. Changed to use current time
for new groups while preserving existing timestamps for known groups.

https://claude.ai/code/session_018rcZvALfF3ND2jfcvBaFo2

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-02-01 23:04:49 +02:00
committed by GitHub
parent df52232763
commit e5b436ab48

View File

@@ -95,14 +95,15 @@ export function storeChatMetadata(chatJid: string, timestamp: string, name?: str
} }
/** /**
* Update chat name without changing timestamp. * Update chat name without changing timestamp for existing chats.
* New chats get the current time as their initial timestamp.
* Used during group metadata sync. * Used during group metadata sync.
*/ */
export function updateChatName(chatJid: string, name: string): void { export function updateChatName(chatJid: string, name: string): void {
db.prepare(` db.prepare(`
INSERT INTO chats (jid, name, last_message_time) VALUES (?, ?, ?) INSERT INTO chats (jid, name, last_message_time) VALUES (?, ?, ?)
ON CONFLICT(jid) DO UPDATE SET name = excluded.name ON CONFLICT(jid) DO UPDATE SET name = excluded.name
`).run(chatJid, name, new Date(0).toISOString()); `).run(chatJid, name, new Date().toISOString());
} }
export interface ChatInfo { export interface ChatInfo {