From e5b436ab48dc92efcfc0176d255714eaadbaabd6 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Sun, 1 Feb 2026 23:04:49 +0200 Subject: [PATCH] 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 --- src/db.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/db.ts b/src/db.ts index 6a15517..0a61867 100644 --- a/src/db.ts +++ b/src/db.ts @@ -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. */ export function updateChatName(chatJid: string, name: string): void { db.prepare(` INSERT INTO chats (jid, name, last_message_time) VALUES (?, ?, ?) 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 {