From 654fde5f6819cb52a198a524ab78d97e51ab97c7 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 2 Apr 2024 20:41:36 +1100 Subject: Support disabling automatic database updates --- src/ui/ui_fsm.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/ui/ui_fsm.cpp') diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 835da19e..bb1503b2 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -282,6 +282,14 @@ lua::Property UiState::sScrollSensitivity{ lua::Property UiState::sLockSwitch{false}; lua::Property UiState::sDatabaseUpdating{false}; +lua::Property UiState::sDatabaseAutoUpdate{ + false, [](const lua::LuaValue& val) { + if (!std::holds_alternative(val)) { + return false; + } + sServices->nvs().DbAutoIndex(std::get(val)); + return true; + }}; lua::Property UiState::sUsbMassStorageEnabled{ false, [](const lua::LuaValue& val) { @@ -557,14 +565,18 @@ void Lua::entry() { "time", { {"ticks", [&](lua_State* s) { return Ticks(s); }}, }); - registry.AddPropertyModule("database", { - {"updating", &sDatabaseUpdating}, - }); + registry.AddPropertyModule("database", + { + {"updating", &sDatabaseUpdating}, + {"auto_update", &sDatabaseAutoUpdate}, + }); registry.AddPropertyModule("usb", { {"msc_enabled", &sUsbMassStorageEnabled}, }); + sDatabaseAutoUpdate.Update(sServices->nvs().DbAutoIndex()); + auto bt = sServices->bluetooth(); sBluetoothEnabled.Update(bt.IsEnabled()); sBluetoothConnected.Update(bt.IsConnected()); -- cgit v1.2.3