From 65d2b5d26ca2d0975dd319b9feb14894cdfaeef7 Mon Sep 17 00:00:00 2001 From: isseysandei Date: Mon, 20 Jan 2025 09:36:30 +0100 Subject: [PATCH] compacted the nested if using ternary operator --- protobufs | 2 +- src/graphics/Screen.cpp | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/protobufs b/protobufs index fde27e4ef..76f806e1b 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit fde27e4ef0fcee967063ba353422ed5f9a1c4790 +Subproject commit 76f806e1bb1e2a7b157a14fadd095775f63db5e4 diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index fed5d17b2..5742d77e1 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -2660,19 +2660,14 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg) return 0; } -int Screen::handleTextMessage(const meshtastic_MeshPacket *packet) -// If auto carousel is disabled, the focus doesn't chage on the incoming message -{ - if (config.display.auto_screen_carousel_secs != 0) { - if (showingNormalScreen) { - // Outgoing message - if (packet->from == 0) - setFrames(FOCUS_PRESERVE); // Return to same frame (quietly hiding the rx text message frame) +int Screen::handleTextMessage(const meshtastic_MeshPacket *packet) { + // If auto carousel is disabled -> return 0 and skip new messages handling + if (config.display.auto_screen_carousel_secs == 0) + return 0; - // Incoming message - else - setFrames(FOCUS_TEXTMESSAGE); // Focus on the new message - } + // Handle focus change based on message type + if (showingNormalScreen) { + setFrames(packet->from == 0 ? FOCUS_PRESERVE : FOCUS_TEXTMESSAGE); } return 0;