From 1ecf2f60f07565b384b28a502dd6fa0abb25cf44 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Tue, 17 Mar 2026 08:35:40 +0100 Subject: [PATCH] fix(dm): resolve conversation name via prefix match for saved IDs When restoring a conversation from localStorage, the saved ID may have a different pubkey prefix length than the API returns (e.g. pk_e4ce0a07 vs pk_e4ce0a075359459f...). Now selectConversation() does prefix matching against dmConversations and upgrades the stored ID, so the display name is resolved correctly instead of showing raw pubkey prefix. Co-Authored-By: Claude Opus 4.6 --- app/static/js/dm.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/static/js/dm.js b/app/static/js/dm.js index 481aefd..e6ece80 100644 --- a/app/static/js/dm.js +++ b/app/static/js/dm.js @@ -469,8 +469,23 @@ async function selectConversation(conversationId) { // Save to localStorage for next visit localStorage.setItem('mc_active_dm_conversation', conversationId); - // Find the conversation to get recipient name - const conv = dmConversations.find(c => c.conversation_id === conversationId); + // Find the conversation to get recipient name (exact or prefix match) + let conv = dmConversations.find(c => c.conversation_id === conversationId); + if (!conv && conversationId.startsWith('pk_')) { + // Partial match: saved ID may have different prefix length than API + const prefix = conversationId.substring(3); + conv = dmConversations.find(c => + c.conversation_id.startsWith('pk_') && + (c.conversation_id.substring(3).startsWith(prefix) || prefix.startsWith(c.conversation_id.substring(3))) + ); + // Upgrade to full conversation_id if found + if (conv) { + conversationId = conv.conversation_id; + currentConversationId = conversationId; + localStorage.setItem('mc_active_dm_conversation', conversationId); + } + } + if (conv && conv.display_name) { currentRecipient = conv.display_name; } else {