From 6d6f59cb94577fb7537b6985c066a38a728fef3b Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 1 Oct 2024 15:46:00 +1000 Subject: [PATCH] Don't enable usb msc when the database is updating --- lua/settings.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lua/settings.lua b/lua/settings.lua index 8e08fd8e..f2a1ec7e 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -336,7 +336,7 @@ settings.ThemeSettings = SettingsScreen:new { local selected_idx = -1 for i, v in pairs(themeOptions) do if (saved_theme == v) then - selected_idx = idx + selected_idx = idx end if idx > 0 then options = options .. "\n" @@ -354,7 +354,7 @@ settings.ThemeSettings = SettingsScreen:new { options = options, symbol = img.chevron, } - theme_chooser:set({selected = selected_idx}) + theme_chooser:set({ selected = selected_idx }) theme_chooser:onevent(lvgl.EVENT.VALUE_CHANGED, function() local option = theme_chooser:get('selected_str') @@ -457,7 +457,7 @@ settings.MassStorageSettings = SettingsScreen:new { local busy_text = self.content:Label { w = lvgl.PCT(100), - text = "USB is currently busy. Do not unplug or remove the SD card.", + text = "", long_mode = lvgl.LABEL.LONG_WRAP, } @@ -470,7 +470,7 @@ settings.MassStorageSettings = SettingsScreen:new { end enable_sw:onevent(lvgl.EVENT.VALUE_CHANGED, function() - if not usb.msc_busy:get() then + if not usb.msc_busy:get() and not database.updating:get() then usb.msc_enabled:set(enable_sw:enabled()) end bind_switch() @@ -484,6 +484,19 @@ settings.MassStorageSettings = SettingsScreen:new { else busy_text:add_flag(lvgl.FLAG.HIDDEN) end + end), + database.updating:bind(function(updating) + if updating then + busy_text:clear_flag(lvgl.FLAG.HIDDEN) + busy_text:set { + text = "Your database is currently updating. Please wait." + } + else + busy_text:add_flag(lvgl.FLAG.HIDDEN) + busy_text:set { + text = "USB is currently busy. Do not unplug or remove the SD card." + } + end end) } end,