From 0e0e5b938a7ecedcc11205a9c7551f4a32b26d46 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Fri, 29 May 2026 10:59:34 +0200 Subject: [PATCH] fix(ui/favourites): pin picker fallback to all contacts When the user presses + on an empty Favourites Dial tile, the picker previously showed 'No fav contacts' if there were no starred contacts (flags & 0x01) AND no recent DMs in _dm_hist (empty after reboot). Add a third fallback tier: when the first two tiers yield nothing, list all ADV_TYPE_CHAT contacts so the user can always pin anyone. Alert text updated to 'No contacts' for the remaining edge case (no contacts at all in the mesh). Known limitation: per-contact unread badges on the dial reset on reboot (in-RAM only). Persisted unread is a separate future improvement. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/UITask.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index b5c5a2ff..3af5ea3b 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -216,8 +216,23 @@ class HomeScreen : public UIScreen { } } } + // 3) Fallback: all remaining chat contacts not already in the list. if (_pin_count == 0) { - _task->showAlert("No fav contacts", 1000); + for (int idx = 0; _pin_count < PIN_PICKER_MAX; idx++) { + ContactInfo c; + if (!the_mesh.getContactByIdx(idx, c)) break; + if (c.type != ADV_TYPE_CHAT) continue; + bool dup = false; + for (int j = 0; j < _pin_count; j++) + if (memcmp(_pin_keys[j], c.id.pub_key, NodePrefs::FAVOURITE_PREFIX_LEN) == 0) { dup = true; break; } + if (dup) continue; + memcpy(_pin_keys[_pin_count], c.id.pub_key, NodePrefs::FAVOURITE_PREFIX_LEN); + DisplayDriver::translateUTF8Static(_pin_labels[_pin_count], c.name, sizeof(_pin_labels[_pin_count])); + _pin_count++; + } + } + if (_pin_count == 0) { + _task->showAlert("No contacts", 1000); _pin_target_slot = -1; return; }