mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-04 19:26:19 +00:00
fix: guard savePrefs with dirty flag in BotScreen and DashboardConfigScreen
BotScreen and DashboardConfigScreen were calling savePrefs() on every exit regardless of whether any setting changed. Add _dirty flag set only on actual value changes (toggle, channel select, keyboard confirm, field cycle), reset on enter(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9e5c0e79e7
commit
85de0b02be
@@ -26,17 +26,19 @@ class DashboardConfigScreen : public UIScreen {
|
||||
|
||||
static const char* OPTION_NAMES[DASH_COUNT];
|
||||
|
||||
int _sel;
|
||||
int _sel;
|
||||
bool _dirty;
|
||||
|
||||
void cycle(int slot, int dir) {
|
||||
uint8_t& f = _prefs->dashboard_fields[slot];
|
||||
f = (uint8_t)((f + DASH_COUNT + dir) % DASH_COUNT);
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
public:
|
||||
DashboardConfigScreen(UITask* task, NodePrefs* prefs) : _task(task), _prefs(prefs) {}
|
||||
|
||||
void enter() { _sel = 0; }
|
||||
void enter() { _sel = 0; _dirty = false; }
|
||||
|
||||
int render(DisplayDriver& display) override {
|
||||
display.setTextSize(1);
|
||||
@@ -67,7 +69,7 @@ public:
|
||||
|
||||
bool handleInput(char c) override {
|
||||
if (c == KEY_CANCEL || c == KEY_CONTEXT_MENU) {
|
||||
the_mesh.savePrefs();
|
||||
if (_dirty) the_mesh.savePrefs();
|
||||
_task->gotoHomeScreen();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user