From 2edbc7dbf71221fba2cab891692eb903535b5b1a Mon Sep 17 00:00:00 2001 From: jjbrunton Date: Fri, 22 May 2026 22:52:04 +0100 Subject: [PATCH] Resolve t2 usernames after every delta sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit enrichUsernames() was only invoked once at startup, so any rooms that arrived via a later delta /sync stayed pinned to their raw t2_xxx identifier — which the dashboard then rendered as a bare Matrix-style ID. Call enrichUsernames() at the tail of syncOnce so new rooms get resolved to real Reddit usernames before the UI reads them. Also pass the unformatted username to openConversation() and format the modal title in the frontend, so lookups by username keep working after the display sanitisation. Co-Authored-By: Claude Opus 4.7 --- public/index.html | 6 +++--- src/services/chat/service.ts | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 9a8baac..93f5bbb 100644 --- a/public/index.html +++ b/public/index.html @@ -2994,7 +2994,7 @@ const displayName = display === 'unknown' ? 'unknown' : 'u/' + escapeHtml(display); const initial = display.charAt(0).toUpperCase() || '?'; return ` -
+
${initial}
@@ -3418,7 +3418,7 @@ const statusBadge = hasReply ? 'Got Reply!' : ''; return ` -
+
${initial}
@@ -3444,7 +3444,7 @@ const modalBody = document.getElementById('modal-body'); openConversationUsername = username; - modalTitle.textContent = `Conversation with u/${username}`; + modalTitle.textContent = `Conversation with u/${formatUsernameRaw(username)}`; // If a sync is in flight, set a clearer placeholder up front instead of bare "Loading…". let placeholderText = 'Loading…'; try { diff --git a/src/services/chat/service.ts b/src/services/chat/service.ts index 3a9ba66..adaf630 100644 --- a/src/services/chat/service.ts +++ b/src/services/chat/service.ts @@ -659,6 +659,9 @@ export class ChatService { this.cache.set(merged); this.cache.markDeltaSync(); await this.cache.save(merged); + // Resolve any t2_-prefixed usernames the delta just introduced, so the + // dashboard doesn't show raw Matrix-style IDs for new rooms. + await this.enrichUsernames(); return merged; }