mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
refactor(ui): extract PopupMenu::beginConfirm() for destructive-action popups
Found while re-reviewing this session's own commits: five screens each hand-built the same 2-row Action/Cancel confirm popup, defaulting the highlight to Cancel -- NearbyScreen's contact-delete, AdminScreen's OTA-start, and the three just added (Trail's reset, Messages' channel delete, RadioPresetPicker's preset delete). The plan that added those three had already flagged this exact duplication without acting on it, so it just tripled instead of getting fixed. One PopupMenu::beginConfirm(title, action_label, cancel_label="Cancel") replaces all five call sites, and makes "defaults to Cancel" a property of the popup itself rather than something each new confirm has to remember. Also drops two small redundancies spotted along the way: NearbyScreen's _confirm.active = true, dead since begin() already sets it, and RadioPresetPicker's deleting = false being set twice in a row (once inside openConfirm(), once again by its only caller). No behavior change; verified against the actual PopupMenu/menu-level state machines in each of the five call sites before touching them.
This commit is contained in:
@@ -238,10 +238,7 @@ class AdminScreen : public UIScreen {
|
||||
} else if (f.set_prefix == nullptr) { // Action
|
||||
if (!strcmp(f.get_cmd, "start ota")) { // see _confirm's comment
|
||||
_pending_confirm_field = &f;
|
||||
_confirm.begin("Start OTA update?", 2);
|
||||
_confirm.addItem("Start");
|
||||
_confirm.addItem("Cancel");
|
||||
_confirm.setSelected(1); // default highlight = Cancel
|
||||
_confirm.beginConfirm("Start OTA update?", "Start");
|
||||
return;
|
||||
}
|
||||
strncpy(_cmd_text, f.get_cmd, sizeof(_cmd_text) - 1);
|
||||
|
||||
Reference in New Issue
Block a user