From 27f00cd1565fb4535c4e0cc6dc53cb1cff9597f2 Mon Sep 17 00:00:00 2001 From: Robert Fisk Date: Sun, 11 Aug 2024 06:50:53 -0400 Subject: [PATCH] Improve popup message handling - Restore old canned message state after displaying message - Don't clear freetext/state after displaying message --- src/modules/CannedMessageModule.cpp | 15 ++++++--------- src/modules/CannedMessageModule.h | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 456c4ad9a..34b0ccc5e 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -406,17 +406,12 @@ int32_t CannedMessageModule::runOnce() if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED) || (this->runState == CANNED_MESSAGE_RUN_STATE_MESSAGE)) { // TODO: might have some feedback of sending state - this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + if (this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { + this->restoreOldState = CANNED_MESSAGE_RUN_STATE_INACTIVE; + } + this->runState = this->restoreOldState; temporaryMessage = ""; e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen - this->currentMessageIndex = -1; - this->freetext = ""; // clear freetext - this->cursor = 0; - -#if !defined(T_WATCH_S3) && !defined(RAK14014) - this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; -#endif - this->notifyObservers(&e); } else if (((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT)) && ((millis() - this->lastTouchMillis) >= INACTIVATE_AFTER_MS)) { @@ -721,6 +716,7 @@ void CannedMessageModule::showTemporaryMessage(const String &message) UIFrameEvent e; e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen notifyObservers(&e); + this->restoreOldState = this->runState; runState = CANNED_MESSAGE_RUN_STATE_MESSAGE; // run this loop again in 2 seconds, next iteration will clear the display setIntervalFromNow(2000); @@ -1088,6 +1084,7 @@ ProcessMessage CannedMessageModule::handleReceived(const meshtastic_MeshPacket & UIFrameEvent e; e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen requestFocus(); // Tell Screen::setFrames that our module's frame should be shown, even if not "first" in the frameset + this->restoreOldState = this->runState; this->runState = CANNED_MESSAGE_RUN_STATE_ACK_NACK_RECEIVED; this->incoming = service->getNodenumFromRequestId(mp.decoded.request_id); meshtastic_Routing decoded = meshtastic_Routing_init_default; diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 368574c40..4723c057d 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -131,6 +131,7 @@ class CannedMessageModule : public SinglePortModule, public Observable