From aedb7f6f5d297f40f3aab6719e2b0be77822c959 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Sun, 24 May 2026 23:24:13 +0200 Subject: [PATCH] fix(ui): Favourites migration even when page_order is full ensurePageOrderInit only inserted FAVOURITES when len < PAGE_ORDER_LEN. Older saves with all 11 slots filled (default order with GPS + SENSORS) hit the full-array branch and were left without FAVOURITES in the explicit order, so the page was shown via the missing-page fallback at end of nav but movePageInOrder couldn't reorder it. Now drop the last entry (typically SHUTDOWN, which the same fallback already re-appends at end of nav) to make room. End result: FAVOURITES sits after CLOCK, reorderable; nav layout matches the new default. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/SettingsScreen.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/ui-new/SettingsScreen.h b/examples/companion_radio/ui-new/SettingsScreen.h index b4d2d40d..77652e13 100644 --- a/examples/companion_radio/ui-new/SettingsScreen.h +++ b/examples/companion_radio/ui-new/SettingsScreen.h @@ -258,10 +258,13 @@ class SettingsScreen : public UIScreen { // Corrupted/partial — full re-init below. memset(p->page_order, 0, sizeof(p->page_order)); } else { - if (!has_fav && len < NodePrefs::PAGE_ORDER_LEN) { - // Insert FAVOURITES right after CLOCK; shift the tail down by one. + if (!has_fav) { + // Insert FAVOURITES right after CLOCK. If the array is full, the last + // entry (typically SHUTDOWN, which still appears via the missing-page + // fallback at end of nav) is overwritten to make room. int insert_at = clock_at + 1; - for (int i = len; i > insert_at; i--) p->page_order[i] = p->page_order[i - 1]; + int tail = (len < NodePrefs::PAGE_ORDER_LEN) ? len : NodePrefs::PAGE_ORDER_LEN - 1; + for (int i = tail; i > insert_at; i--) p->page_order[i] = p->page_order[i - 1]; p->page_order[insert_at] = NodePrefs::HPB_FAVOURITES + 1; } return;