From 422a3492cf0d2ee28dddd1746b752946245955a2 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 10 Jul 2024 14:31:20 +0100 Subject: [PATCH] 0.74: Add extra layer of checks before allowing a factory reset (fix #3476) --- apps/setting/ChangeLog | 1 + apps/setting/metadata.json | 2 +- apps/setting/settings.js | 20 +++++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/setting/ChangeLog b/apps/setting/ChangeLog index 3be7db96af..27aa5c90c4 100644 --- a/apps/setting/ChangeLog +++ b/apps/setting/ChangeLog @@ -82,3 +82,4 @@ of 'Select Clock' 0.71: Minor code improvements 0.72: Add setting for configuring BLE privacy 0.73: Fix `const` bug / work with fastload +0.74: Add extra layer of checks before allowing a factory reset (fix #3476) \ No newline at end of file diff --git a/apps/setting/metadata.json b/apps/setting/metadata.json index 44774dc087..67ca847d9f 100644 --- a/apps/setting/metadata.json +++ b/apps/setting/metadata.json @@ -1,7 +1,7 @@ { "id": "setting", "name": "Settings", - "version": "0.73", + "version": "0.74", "description": "A menu for setting up Bangle.js", "icon": "settings.png", "tags": "tool,system", diff --git a/apps/setting/settings.js b/apps/setting/settings.js index b348e00d5f..d8ecefd929 100644 --- a/apps/setting/settings.js +++ b/apps/setting/settings.js @@ -702,14 +702,24 @@ function showUtilMenu() { } }); }; - if (Bangle.factoryReset) { menu[/*LANG*/'Factory Reset'] = ()=>{ - E.showPrompt(/*LANG*/'This will remove everything!',{title:/*LANG*/"Factory Reset"}).then((v) => { + E.showPrompt(/*LANG*/'This will remove everything!',{title:/*LANG*/"Factory Reset",back:showUtilMenu}).then((v) => { if (v) { - E.showMessage(); - Terminal.setConsole(); - Bangle.factoryReset(); + var n = ((Math.random()*4)&3) + 1; + E.showPrompt(/*LANG*/"To confirm, please press "+n,{ + title:/*LANG*/"Factory Reset", + buttons : {"1":1,"2":2,"3":3,"4":4}, + back:showUtilMenu + }).then(function(v) { + if (v==n) { + E.showMessage(); + Terminal.setConsole(); + Bangle.factoryReset(); + } else { + showUtilMenu(); + } + }); } else showUtilMenu(); }); }