From c323967b6acd75a53c0eb159524258e6215ccf1c Mon Sep 17 00:00:00 2001 From: Mikayla Date: Tue, 20 Aug 2024 20:52:38 +0000 Subject: [PATCH 1/2] #536 fix for clearing settings --- coordinator/configure.lua | 4 +++- coordinator/startup.lua | 2 +- pocket/configure.lua | 4 +++- pocket/startup.lua | 2 +- reactor-plc/config/system.lua | 4 +++- reactor-plc/startup.lua | 2 +- rtu/configure.lua | 4 +++- rtu/startup.lua | 2 +- supervisor/configure.lua | 4 +++- supervisor/startup.lua | 2 +- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/coordinator/configure.lua b/coordinator/configure.lua index fb29193..94be17b 100644 --- a/coordinator/configure.lua +++ b/coordinator/configure.lua @@ -959,7 +959,9 @@ local function config_view(display) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do settings.set(k, v) end + for k, v in pairs(tmp_cfg) do + if v == nil then settings.unset(k) else settings.set(k, v) end + end if settings.save("/coordinator.settings") then load_settings(settings_cfg, true) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 15a9999..62d1511 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer") local sounder = require("coordinator.sounder") local threads = require("coordinator.threads") -local COORDINATOR_VERSION = "v1.5.2" +local COORDINATOR_VERSION = "v1.5.3" local CHUNK_LOAD_DELAY_S = 30.0 diff --git a/pocket/configure.lua b/pocket/configure.lua index 0002383..5ebcdd2 100644 --- a/pocket/configure.lua +++ b/pocket/configure.lua @@ -379,7 +379,9 @@ local function config_view(display) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do settings.set(k, v) end + for k, v in pairs(tmp_cfg) do + if v == nil then settings.unset(k) else settings.set(k, v) end + end if settings.save("/pocket.settings") then load_settings(settings_cfg, true) diff --git a/pocket/startup.lua b/pocket/startup.lua index d0394c0..b39cc53 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -20,7 +20,7 @@ local pocket = require("pocket.pocket") local renderer = require("pocket.renderer") local threads = require("pocket.threads") -local POCKET_VERSION = "v0.11.4-alpha" +local POCKET_VERSION = "v0.11.5-alpha" local println = util.println local println_ts = util.println_ts diff --git a/reactor-plc/config/system.lua b/reactor-plc/config/system.lua index 46f5afc..dc8250b 100644 --- a/reactor-plc/config/system.lua +++ b/reactor-plc/config/system.lua @@ -450,7 +450,9 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do settings.set(k, v) end + for k, v in pairs(tmp_cfg) do + if v == nil then settings.unset(k) else settings.set(k, v) end + end if settings.save("/reactor-plc.settings") then load_settings(settings_cfg, true) diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 1bc863a..12e63a0 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.8.3" +local R_PLC_VERSION = "v1.8.4" local println = util.println local println_ts = util.println_ts diff --git a/rtu/configure.lua b/rtu/configure.lua index b5cceeb..6a9eccc 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -651,7 +651,9 @@ local function config_view(display) ---@param exclude_conns boolean? true to exclude saving peripheral/redstone connections local function save_and_continue(exclude_conns) for k, v in pairs(tmp_cfg) do - if not (exclude_conns and (k == "Peripherals" or k == "Redstone")) then settings.set(k, v) end + if not (exclude_conns and (k == "Peripherals" or k == "Redstone")) then + if v == nil then settings.unset(k) else settings.set(k, v) end + end end -- always set these if missing diff --git a/rtu/startup.lua b/rtu/startup.lua index 5f53bee..479eff0 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.10.3" +local RTU_VERSION = "v1.10.4" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE diff --git a/supervisor/configure.lua b/supervisor/configure.lua index 982550a..57879b6 100644 --- a/supervisor/configure.lua +++ b/supervisor/configure.lua @@ -907,7 +907,9 @@ local function config_view(display) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do settings.set(k, v) end + for k, v in pairs(tmp_cfg) do + if v == nil then settings.unset(k) else settings.set(k, v) end + end if settings.save("/supervisor.settings") then load_settings(settings_cfg, true) diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 5ea8f6a..2d5337b 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.4.3" +local SUPERVISOR_VERSION = "v1.4.4" local println = util.println local println_ts = util.println_ts From 6917697290d5cfb96cb5c23fe5a4dccd7ca5f9d4 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Tue, 20 Aug 2024 20:56:41 -0400 Subject: [PATCH 2/2] #536 proper clearing of cleared config values --- coordinator/configure.lua | 3 ++- coordinator/startup.lua | 2 +- pocket/configure.lua | 3 ++- pocket/startup.lua | 2 +- reactor-plc/config/system.lua | 3 ++- reactor-plc/startup.lua | 2 +- rtu/configure.lua | 3 ++- rtu/startup.lua | 2 +- supervisor/configure.lua | 3 ++- supervisor/startup.lua | 2 +- 10 files changed, 15 insertions(+), 10 deletions(-) diff --git a/coordinator/configure.lua b/coordinator/configure.lua index 94be17b..100b079 100644 --- a/coordinator/configure.lua +++ b/coordinator/configure.lua @@ -959,7 +959,8 @@ local function config_view(display) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do + for _, field in ipairs(fields) do + local k, v = field[1], tmp_cfg[field[1]] if v == nil then settings.unset(k) else settings.set(k, v) end end diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 62d1511..e31ca60 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -19,7 +19,7 @@ local renderer = require("coordinator.renderer") local sounder = require("coordinator.sounder") local threads = require("coordinator.threads") -local COORDINATOR_VERSION = "v1.5.3" +local COORDINATOR_VERSION = "v1.5.4" local CHUNK_LOAD_DELAY_S = 30.0 diff --git a/pocket/configure.lua b/pocket/configure.lua index 5ebcdd2..783cf9a 100644 --- a/pocket/configure.lua +++ b/pocket/configure.lua @@ -379,7 +379,8 @@ local function config_view(display) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do + for _, field in ipairs(fields) do + local k, v = field[1], tmp_cfg[field[1]] if v == nil then settings.unset(k) else settings.set(k, v) end end diff --git a/pocket/startup.lua b/pocket/startup.lua index b39cc53..ed3f36f 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -20,7 +20,7 @@ local pocket = require("pocket.pocket") local renderer = require("pocket.renderer") local threads = require("pocket.threads") -local POCKET_VERSION = "v0.11.5-alpha" +local POCKET_VERSION = "v0.11.6-alpha" local println = util.println local println_ts = util.println_ts diff --git a/reactor-plc/config/system.lua b/reactor-plc/config/system.lua index dc8250b..1486170 100644 --- a/reactor-plc/config/system.lua +++ b/reactor-plc/config/system.lua @@ -450,7 +450,8 @@ function system.create(tool_ctl, main_pane, cfg_sys, divs, style, exit) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do + for _, field in ipairs(fields) do + local k, v = field[1], tmp_cfg[field[1]] if v == nil then settings.unset(k) else settings.set(k, v) end end diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 12e63a0..b83f9df 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.8.4" +local R_PLC_VERSION = "v1.8.5" local println = util.println local println_ts = util.println_ts diff --git a/rtu/configure.lua b/rtu/configure.lua index 6a9eccc..943c248 100644 --- a/rtu/configure.lua +++ b/rtu/configure.lua @@ -650,7 +650,8 @@ local function config_view(display) ---@param exclude_conns boolean? true to exclude saving peripheral/redstone connections local function save_and_continue(exclude_conns) - for k, v in pairs(tmp_cfg) do + for _, field in ipairs(fields) do + local k, v = field[1], tmp_cfg[field[1]] if not (exclude_conns and (k == "Peripherals" or k == "Redstone")) then if v == nil then settings.unset(k) else settings.set(k, v) end end diff --git a/rtu/startup.lua b/rtu/startup.lua index 479eff0..cbaada7 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.10.4" +local RTU_VERSION = "v1.10.5" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE diff --git a/supervisor/configure.lua b/supervisor/configure.lua index 57879b6..59be74f 100644 --- a/supervisor/configure.lua +++ b/supervisor/configure.lua @@ -907,7 +907,8 @@ local function config_view(display) end local function save_and_continue() - for k, v in pairs(tmp_cfg) do + for _, field in ipairs(fields) do + local k, v = field[1], tmp_cfg[field[1]] if v == nil then settings.unset(k) else settings.set(k, v) end end diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 2d5337b..f5999a7 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.4.4" +local SUPERVISOR_VERSION = "v1.4.5" local println = util.println local println_ts = util.println_ts