From 9aadce2262956f25268030518617da986b6c4bf2 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 9 Jun 2026 07:45:40 +0200 Subject: [PATCH] refactor(QuickMsgScreen): extract markReadAlert() helper Deduplicate the snprintf+showAlert pattern used in three mark-as-read sites into a single private method. Co-Authored-By: Claude Sonnet 4.6 --- .../companion_radio/ui-new/QuickMsgScreen.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/companion_radio/ui-new/QuickMsgScreen.h b/examples/companion_radio/ui-new/QuickMsgScreen.h index 046000b2..34bf7f70 100644 --- a/examples/companion_radio/ui-new/QuickMsgScreen.h +++ b/examples/companion_radio/ui-new/QuickMsgScreen.h @@ -551,6 +551,12 @@ public: return total; } + void markReadAlert(int n) { + char msg[32]; + snprintf(msg, sizeof(msg), "%d marked read", n); + _task->showAlert(msg, 800); + } + void clearAllChannelUnread() { memset(_ch_unread, 0, sizeof(_ch_unread)); } @@ -1116,9 +1122,7 @@ public: cleared = _task->getRoomUnreadCount(); _task->clearRoomUnread(); } - char msg[32]; - snprintf(msg, sizeof(msg), "%d marked read", cleared); - _task->showAlert(msg, 800); + markReadAlert(cleared); } return true; } @@ -1199,9 +1203,7 @@ public: if (sel == 0) { int cleared = (int)_task->getDMUnread(ci.id.pub_key); _task->clearDMUnread(ci.id.pub_key); - char msg[32]; - snprintf(msg, sizeof(msg), "%d marked read", cleared); - _task->showAlert(msg, 800); + markReadAlert(cleared); } else if (sel == 3) { // Pin / Unpin int pinned_slot = _task->findFavouriteSlot(ci.id.pub_key); @@ -1333,9 +1335,7 @@ public: if (sel == 0) { int cleared = (int)_ch_unread[ch_idx]; _ch_unread[ch_idx] = 0; - char msg[32]; - snprintf(msg, sizeof(msg), "%d marked read", cleared); - _task->showAlert(msg, 800); + markReadAlert(cleared); } // sel 1/2/3 already handled by LEFT/RIGHT; ENTER just closes. }