From 0b8b757fb0a5a2de600a1c1a13e486ba8df92eec Mon Sep 17 00:00:00 2001 From: Jason P Date: Mon, 2 Feb 2026 12:00:42 -0600 Subject: [PATCH] Rename variable, set max status to 20, added Node List View. --- src/graphics/draw/NodeListRenderer.cpp | 40 ++++++++++++++++++++++++-- src/modules/StatusMessageModule.cpp | 4 +-- src/modules/StatusMessageModule.h | 6 ++-- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/graphics/draw/NodeListRenderer.cpp b/src/graphics/draw/NodeListRenderer.cpp index 9d6780130..1fa186b63 100644 --- a/src/graphics/draw/NodeListRenderer.cpp +++ b/src/graphics/draw/NodeListRenderer.cpp @@ -3,6 +3,9 @@ #include "CompassRenderer.h" #include "NodeDB.h" #include "NodeListRenderer.h" +#if !MESHTASTIC_EXCLUDE_STATUS +#include "modules/StatusMessageModule.h" +#endif #include "UIRenderer.h" #include "gps/GeoCoord.h" #include "gps/RTC.h" // for getTime() function @@ -90,8 +93,41 @@ const char *getSafeNodeName(OLEDDisplay *display, meshtastic_NodeInfoLite *node, // 1) Choose target candidate (long vs short) only if present const char *raw = nullptr; - if (node && node->has_user) { - raw = config.display.use_long_node_name ? node->user.long_name : node->user.short_name; + +#if !MESHTASTIC_EXCLUDE_STATUS + // If long-name mode is enabled, and we have a recent status for this node, + // prefer "(short_name) statusText" as the raw candidate. + std::string composedFromStatus; + if (config.display.use_long_node_name && node && node->has_user && statusMessageModule) { + const auto &recent = statusMessageModule->getRecentReceived(); + const StatusMessageModule::RecentStatus *found = nullptr; + for (auto it = recent.rbegin(); it != recent.rend(); ++it) { + if (it->fromNodeId == node->num && !it->statusText.empty()) { + found = &(*it); + break; + } + } + + if (found) { + const char *shortName = node->user.short_name; + composedFromStatus.reserve(4 + (shortName ? std::strlen(shortName) : 0) + 1 + found->statusText.size()); + composedFromStatus += "("; + if (shortName && *shortName) { + composedFromStatus += shortName; + } + composedFromStatus += ") "; + composedFromStatus += found->statusText; + + raw = composedFromStatus.c_str(); // safe for now; we'll sanitize immediately into std::string + } + } +#endif + + // If we didn't compose from status, use normal long/short selection + if (!raw) { + if (node && node->has_user) { + raw = config.display.use_long_node_name ? node->user.long_name : node->user.short_name; + } } // 2) Sanitize (empty if raw is null/empty) diff --git a/src/modules/StatusMessageModule.cpp b/src/modules/StatusMessageModule.cpp index 545a5ec33..0707a4f7d 100644 --- a/src/modules/StatusMessageModule.cpp +++ b/src/modules/StatusMessageModule.cpp @@ -42,8 +42,8 @@ ProcessMessage StatusMessageModule::handleReceived(const meshtastic_MeshPacket & recentReceived.push_back(std::move(entry)); - // Keep only last MAX_RECENT - if (recentReceived.size() > MAX_RECENT) { + // Keep only last MAX_RECENT_STATUSMESSAGES + if (recentReceived.size() > MAX_RECENT_STATUSMESSAGES) { recentReceived.erase(recentReceived.begin()); // drop oldest } } diff --git a/src/modules/StatusMessageModule.h b/src/modules/StatusMessageModule.h index fe65695d8..57e612750 100644 --- a/src/modules/StatusMessageModule.h +++ b/src/modules/StatusMessageModule.h @@ -21,8 +21,8 @@ class StatusMessageModule : public SinglePortModule, private concurrency::OSThre } // TODO: If we have a string, set the initial delay (15 minutes maybe) - // Keep vector from reallocating as we fill up to MAX_RECENT - recentReceived.reserve(MAX_RECENT); + // Keep vector from reallocating as we fill up to MAX_RECENT_STATUSMESSAGES + recentReceived.reserve(MAX_RECENT_STATUSMESSAGES); } virtual int32_t runOnce() override; @@ -40,7 +40,7 @@ class StatusMessageModule : public SinglePortModule, private concurrency::OSThre virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override; private: - static constexpr size_t MAX_RECENT = 5; + static constexpr size_t MAX_RECENT_STATUSMESSAGES = 20; std::vector recentReceived; };