Align Meshtastic phone sync and chat UI refresh

This commit is contained in:
liu weikai
2026-03-27 22:32:51 +08:00
parent df76526b5d
commit e0076d707b
18 changed files with 1003 additions and 49 deletions
@@ -425,6 +425,7 @@ void UiController::onChatEvent(sys::Event* event)
if (is_current_conversation)
{
(void)updateConversationViewForIncoming(*latest);
reloadConversationView();
service_.markConversationRead(current_conv_);
}
else
@@ -444,13 +445,7 @@ void UiController::onChatEvent(sys::Event* event)
const ChatMessage* msg = service_.getMessage(result_event->msg_id);
if (!msg || !conversation_->updateMessageStatus(result_event->msg_id, msg->status))
{
auto messages = service_.getRecentMessages(current_conv_, 50);
conversation_->clearMessages();
for (const auto& m : messages)
{
conversation_->addMessage(m);
}
conversation_->scrollToBottom();
reloadConversationView();
}
}
(void)result_event;
@@ -912,6 +907,22 @@ bool UiController::updateConversationViewForIncoming(const chat::ChatMessage& ms
return true;
}
void UiController::reloadConversationView()
{
if (!conversation_ || team_conv_active_)
{
return;
}
auto messages = service_.getRecentMessages(current_conv_, 50);
conversation_->clearMessages();
for (const auto& msg : messages)
{
conversation_->addMessage(msg);
}
conversation_->scrollToBottom();
}
bool UiController::isTeamConversation(const chat::ConversationId& conv) const
{
return isTeamConversationId(conv);
@@ -2087,7 +2087,8 @@ static void start_selected_node_key_verification()
}
if (!node->has_public_key)
{
::ui::SystemNotification::show("No public key yet", 1800);
const bool requested = mesh->requestNodeInfo(node->node_id, true);
::ui::SystemNotification::show(requested ? "Requesting node info" : "No public key yet", 1800);
contacts_focus_to_list();
return;
}
@@ -2100,7 +2101,9 @@ static void start_selected_node_key_verification()
static void toggle_selected_node_key_trust()
{
const auto* node = get_selected_node();
if (!node || !g_contacts_state.contact_service)
app::IAppFacade& app_ctx = app::appFacade();
chat::IMeshAdapter* mesh = app_ctx.getMeshAdapter();
if (!node || !g_contacts_state.contact_service || !mesh)
{
::ui::SystemNotification::show("Key trust unavailable", 1800);
contacts_focus_to_list();
@@ -2108,7 +2111,8 @@ static void toggle_selected_node_key_trust()
}
if (!node->has_public_key)
{
::ui::SystemNotification::show("No public key yet", 1800);
const bool requested = mesh->requestNodeInfo(node->node_id, true);
::ui::SystemNotification::show(requested ? "Requesting node info" : "No public key yet", 1800);
contacts_focus_to_list();
return;
}