mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
fix(home-pages): stop Favourites re-enabling on update; add Map visibility toggle
The prefs schema-migration block runs on every SCHEMA_SENTINEL mismatch, and the "turn Favourites on" step was ungated. Since each firmware release bumps the sentinel, every update re-applied `home_pages_mask |= HP_FAVOURITES`, clobbering a user who had hidden it. Gate it to the transition that added Favourites (sentinel < 0xC0DE0002), matching the trail_units_idx migration. The Map/Trail carousel page shipped with no visibility toggle: pageBit(MAP) returned -1 so it was always visible with no Settings row. Add a proper "Map" toggle (new HPB_MAP/HP_MAP bit, pageBit/bitToPage cases, HOME_MAP settings row) plus a gated one-time migration (sentinel < 0xC0DE0018) that keeps it visible for upgraders. Bump SCHEMA_SENTINEL to 0xC0DE0018; page_order[] stays a literal 11 so the persisted layout is unchanged. Also fix the fresh-install seed, which used a stale 0x01FF literal that left Favourites hidden on new installs despite its "all pages visible" comment; seed NodePrefs::HP_ALL so fresh installs match upgraders (Favourites + Map). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -469,12 +469,21 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
|
||||
if (sentinel != NodePrefs::SCHEMA_SENTINEL) {
|
||||
MESH_DEBUG_PRINTLN("prefs schema sentinel mismatch: got 0x%08X, expected 0x%08X — re-saving on next change",
|
||||
(unsigned)sentinel, (unsigned)NodePrefs::SCHEMA_SENTINEL);
|
||||
// 0xC0DE0001 → 0xC0DE0002: FAVOURITES home page added. Older saves have it
|
||||
// implicitly off (their mask doesn't include HP_FAVOURITES); turn it on so
|
||||
// upgraded users see the new page by default and can toggle it later.
|
||||
if (_prefs.home_pages_mask != 0) {
|
||||
// 0xC0DE0001 → 0xC0DE0002: FAVOURITES home page added. Only pre-0x0002 saves
|
||||
// lack the bit; turn it on once so those upgraders see the new page by
|
||||
// default. Must be gated to that transition — running it on every sentinel
|
||||
// mismatch (as it did) re-enabled Favourites on each firmware update,
|
||||
// clobbering a user who had deliberately hidden it.
|
||||
if (sentinel < 0xC0DE0002 && _prefs.home_pages_mask != 0) {
|
||||
_prefs.home_pages_mask |= NodePrefs::HP_FAVOURITES;
|
||||
}
|
||||
// 0xC0DE0017 → 0xC0DE0018: MAP home page moved into home_pages_mask (it was
|
||||
// always-on before, with no visibility toggle). Turn its bit on once for
|
||||
// pre-0x0018 saves so upgraders keep seeing the page; gated to this
|
||||
// transition so a user who later hides it isn't overridden on the next update.
|
||||
if (sentinel < 0xC0DE0018 && _prefs.home_pages_mask != 0) {
|
||||
_prefs.home_pages_mask |= NodePrefs::HP_MAP;
|
||||
}
|
||||
// 0xC0DE0003 → 0xC0DE0004: trail_units_idx added after trail_min_delta_idx.
|
||||
// On a 0xC0DE0003 file the sentinel bytes sit where trail_units_idx is now,
|
||||
// so rd() picks up 0x03 (low byte of the old sentinel) — reset just that
|
||||
|
||||
Reference in New Issue
Block a user