feat(ui): open DM from filled Favourites tile

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 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-25 07:52:56 +02:00
parent bee8e7c3dd
commit fd37b84d71
3 changed files with 40 additions and 2 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();