mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-03-29 05:19:50 +00:00
Fix conversation list showing hashes instead of display names after restart
After boot, the conversation list called recall_app_data() once during initial load. If announces hadn't arrived yet (or known destinations hadn't been loaded with app_data), conversations showed raw hashes permanently until the user navigated away and back. Add a lazy name resolution check to update_status() (called every 3s): if any conversations have unresolved names, try recall_app_data() again and refresh the list when a display name becomes available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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<Bytes> 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) {
|
||||
|
||||
@@ -197,6 +197,7 @@ private:
|
||||
std::vector<lv_obj_t*> _conversation_containers; // For focus group management
|
||||
std::vector<RNS::Bytes> _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;
|
||||
|
||||
Reference in New Issue
Block a user