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 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-29 10:59:34 +02:00
parent 096b6720b6
commit 0e0e5b938a

View File

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