From ee867f2dbcad624948d73253577ef4bf887cbfad Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 1 Feb 2024 11:43:01 +1100 Subject: add an indicator for database updates --- src/ui/ui_fsm.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ui/ui_fsm.cpp') diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index fe790816..228e61b6 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -11,6 +11,7 @@ #include #include "bluetooth_types.hpp" +#include "db_events.hpp" #include "freertos/portmacro.h" #include "freertos/projdefs.h" #include "lua.h" @@ -213,6 +214,8 @@ lua::Property UiState::sControlsScheme{ return true; }}; +lua::Property UiState::sDatabaseUpdating{false}; + auto UiState::InitBootSplash(drivers::IGpios& gpios) -> bool { // Init LVGL first, since the display driver registers itself with LVGL. lv_init(); @@ -258,6 +261,14 @@ void UiState::react(const internal::ControlSchemeChanged&) { sInput->mode(sServices->nvs().PrimaryInput()); } +void UiState::react(const database::event::UpdateStarted&) { + sDatabaseUpdating.Update(true); +} + +void UiState::react(const database::event::UpdateFinished&) { + sDatabaseUpdating.Update(false); +} + void UiState::react(const internal::DismissAlerts&) { lv_obj_clean(sAlertContainer); } @@ -435,6 +446,10 @@ void Lua::entry() { {"show", [&](lua_State* s) { return ShowAlert(s); }}, {"hide", [&](lua_State* s) { return HideAlert(s); }}, }); + sLua->bridge().AddPropertyModule("database", + { + {"updating", &sDatabaseUpdating}, + }); auto bt = sServices->bluetooth(); sBluetoothEnabled.Update(bt.IsEnabled()); -- cgit v1.2.3