From fd37b84d71da2ca275df57b562cf1d7f8a4365f2 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Mon, 25 May 2026 07:52:56 +0200 Subject: [PATCH] feat(ui): open DM from filled Favourites tile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enter on a populated slot of the Favourites grid now jumps straight into that contact's DM history — resolves the pinned 6-byte pub_key prefix against the contact list, then routes through new UITask::openContactDM(ci) which resets QuickMsgScreen and calls enterDM() to land directly in DM_HIST. Empty slots still show the "pin from contact options" hint until phase 3 wires the in-grid mini-picker. Co-Authored-By: Claude Sonnet 4.6 --- .../companion_radio/ui-new/QuickMsgScreen.h | 12 ++++++++ examples/companion_radio/ui-new/UITask.cpp | 29 +++++++++++++++++-- examples/companion_radio/ui-new/UITask.h | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/ui-new/QuickMsgScreen.h b/examples/companion_radio/ui-new/QuickMsgScreen.h index c151d375..22cddcbe 100644 --- a/examples/companion_radio/ui-new/QuickMsgScreen.h +++ b/examples/companion_radio/ui-new/QuickMsgScreen.h @@ -473,6 +473,18 @@ public: _viewing_max_seen = 0; } + // Jump straight into a contact's DM history (used by the Favourites dial). + // Caller must have already reset() the screen. + void enterDM(const ContactInfo& ci) { + _sel_contact = ci; + _task->clearDMUnread(ci.id.pub_key); + _dm_hist_sel = -1; + _dm_hist_scroll = 0; + _dm_fs.active = false; + _room_mode = false; + _phase = DM_HIST; + } + int render(DisplayDriver& display) override { display.setTextSize(1); display.setColor(DisplayDriver::LIGHT); diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 10483e8f..68058b22 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -860,8 +860,27 @@ public: if (c == KEY_UP && row > 0) { _fav_sel -= cols; return true; } if (c == KEY_DOWN && row < rows - 1) { _fav_sel += cols; return true; } if (c == KEY_ENTER) { - // Phase 2/3 wires this: open DM if filled, picker if empty. Consume for now. - _task->showAlert("Pin from contact options", 1000); + // Filled slot → open the DM directly. Empty slot waits for phase 3 + // (mini-picker); for now show the pin hint. + NodePrefs* p = _task->getNodePrefs(); + const uint8_t* pfx = (p && _fav_sel < NodePrefs::FAVOURITES_COUNT) + ? p->favourite_contacts[_fav_sel] : nullptr; + bool filled = false; + if (pfx) for (uint8_t b = 0; b < NodePrefs::FAVOURITE_PREFIX_LEN; b++) + if (pfx[b]) { filled = true; break; } + if (filled) { + for (int idx = 0; ; idx++) { + ContactInfo c2; + if (!the_mesh.getContactByIdx(idx, c2)) break; + if (memcmp(c2.id.pub_key, pfx, NodePrefs::FAVOURITE_PREFIX_LEN) == 0) { + _task->openContactDM(c2); + return true; + } + } + _task->showAlert("Contact not found", 800); + } else { + _task->showAlert("Pin from contact options", 1000); + } return true; } // Edge LEFT/RIGHT and unhandled keys fall through to page nav below. @@ -1046,6 +1065,12 @@ void UITask::gotoQuickMsgScreen() { setCurrScreen(quick_msg); } +void UITask::openContactDM(const ContactInfo& ci) { + ((QuickMsgScreen*)quick_msg)->reset(); + ((QuickMsgScreen*)quick_msg)->enterDM(ci); + setCurrScreen(quick_msg); +} + void UITask::addChannelMsg(uint8_t channel_idx, const char* text) { _last_notif_ch_idx = (int)channel_idx; ((QuickMsgScreen*)quick_msg)->addChannelMsg(channel_idx, text); diff --git a/examples/companion_radio/ui-new/UITask.h b/examples/companion_radio/ui-new/UITask.h index aef1c4f1..9edf385f 100644 --- a/examples/companion_radio/ui-new/UITask.h +++ b/examples/companion_radio/ui-new/UITask.h @@ -108,6 +108,7 @@ public: void gotoHomeScreen() { setCurrScreen(home); } void gotoSettingsScreen(); void gotoQuickMsgScreen(); + void openContactDM(const ContactInfo& ci); void gotoToolsScreen(); void gotoRingtoneEditor(int slot = 0); void gotoBotScreen();