diff --git a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp index cd33326e..27ef06d4 100644 --- a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp +++ b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.cpp @@ -195,6 +195,7 @@ void ConversationListScreen::refresh() { _conversations.clear(); _conversation_containers.clear(); _peer_hash_pool.clear(); + _has_unresolved_names = false; // Load conversations from store std::vector peer_hashes = _message_store->get_conversations(); @@ -226,17 +227,22 @@ void ConversationListScreen::refresh() { item.peer_hash = peer_hash; // Try to get display name from app_data, fall back to hash + bool resolved = false; Bytes app_data = Identity::recall_app_data(peer_hash); if (app_data && app_data.size() > 0) { String display_name = parse_display_name(app_data); if (display_name.length() > 0) { item.peer_name = display_name; + resolved = true; } else { item.peer_name = truncate_hash(peer_hash); } } else { item.peer_name = truncate_hash(peer_hash); } + if (!resolved) { + _has_unresolved_names = true; + } // Get message content for preview String content((const char*)last_msg.content().data(), last_msg.content().size()); @@ -544,6 +550,23 @@ void ConversationListScreen::update_status() { lv_obj_set_style_text_color(_label_battery_icon, battery_color, 0); lv_obj_set_style_text_color(_label_battery_pct, battery_color, 0); } + + // Check if any unresolved display names can now be resolved + // (announces may have arrived since the list was last refreshed) + if (_has_unresolved_names && _message_store) { + for (const auto& item : _conversations) { + Bytes app_data = Identity::recall_app_data(item.peer_hash); + if (app_data && app_data.size() > 0) { + String name = parse_display_name(app_data); + if (name.length() > 0 && item.peer_name != name) { + // A name has become available — refresh the whole list + DEBUG("Display name resolved, refreshing conversation list"); + refresh(); + return; + } + } + } + } } void ConversationListScreen::on_conversation_clicked(lv_event_t* event) { diff --git a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h index 0984fb69..2606bce3 100644 --- a/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h +++ b/lib/tdeck_ui/UI/LXMF/ConversationListScreen.h @@ -197,6 +197,7 @@ private: std::vector _conversation_containers; // For focus group management std::vector _peer_hash_pool; // Object pool to avoid per-item allocations RNS::Bytes _pending_delete_hash; // Hash of conversation pending deletion + bool _has_unresolved_names = false; // True if any conversation shows hash instead of name ConversationSelectedCallback _conversation_selected_callback; ComposeCallback _compose_callback;