Resolve t2 usernames after every delta sync
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9b9a79bdd
commit
2edbc7dbf7
2 files changed
+6
-3
No files matched your search
+3
-3
@@ -2994,7 +2994,7 @@
|
|||||||
const displayName = display === 'unknown' ? 'unknown' : 'u/' + escapeHtml(display);
|
const displayName = display === 'unknown' ? 'unknown' : 'u/' + escapeHtml(display);
|
||||||
const initial = display.charAt(0).toUpperCase() || '?';
|
const initial = display.charAt(0).toUpperCase() || '?';
|
||||||
return `
|
return `
|
||||||
<div class="chat-item ${chat.unread ? 'unread' : ''}" style="cursor: pointer;" onclick="openConversation('${escapeHtml(display)}')">
|
<div class="chat-item ${chat.unread ? 'unread' : ''}" style="cursor: pointer;" onclick="openConversation('${escapeHtml(chat.username)}')">
|
||||||
<div class="chat-avatar">${initial}</div>
|
<div class="chat-avatar">${initial}</div>
|
||||||
<div class="chat-content">
|
<div class="chat-content">
|
||||||
<div class="chat-header">
|
<div class="chat-header">
|
||||||
@@ -3418,7 +3418,7 @@
|
|||||||
const statusBadge = hasReply ? '<span class="reply-indicator">Got Reply!</span>' : '';
|
const statusBadge = hasReply ? '<span class="reply-indicator">Got Reply!</span>' : '';
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="${cardClass}" onclick="openConversation('${escapeHtml(display)}')">
|
<div class="${cardClass}" onclick="openConversation('${escapeHtml(conv.username)}')">
|
||||||
<div class="chat-avatar">${initial}</div>
|
<div class="chat-avatar">${initial}</div>
|
||||||
<div class="chat-content">
|
<div class="chat-content">
|
||||||
<div class="chat-header">
|
<div class="chat-header">
|
||||||
@@ -3444,7 +3444,7 @@
|
|||||||
const modalBody = document.getElementById('modal-body');
|
const modalBody = document.getElementById('modal-body');
|
||||||
|
|
||||||
openConversationUsername = username;
|
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…".
|
// If a sync is in flight, set a clearer placeholder up front instead of bare "Loading…".
|
||||||
let placeholderText = 'Loading…';
|
let placeholderText = 'Loading…';
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -659,6 +659,9 @@ export class ChatService {
|
|||||||
this.cache.set(merged);
|
this.cache.set(merged);
|
||||||
this.cache.markDeltaSync();
|
this.cache.markDeltaSync();
|
||||||
await this.cache.save(merged);
|
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;
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user