diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-08-28 12:45:10 +1000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-08-28 04:07:21 +0000 |
| commit | 9ec8d6dafcee6c9722672eefad28ee3aeba4feb9 (patch) | |
| tree | 7fc8068ff4cd70bee413d29b0dd9e52b7d6c2cf2 /src/tangara/ui/ui_fsm.cpp | |
| parent | d3c15bf070ff6214cd48fa04027ee5d105bc38b7 (diff) | |
| download | tangara-fw-9ec8d6dafcee6c9722672eefad28ee3aeba4feb9.tar.gz | |
Handle the loading state whilst appending many tracks better
1) Update the queue length periodically so that the user can see we're
working
2) Clear any previous track and display "loading..." instead
Diffstat (limited to 'src/tangara/ui/ui_fsm.cpp')
| -rw-r--r-- | src/tangara/ui/ui_fsm.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index 38e9b8e1..7da07215 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -225,6 +225,7 @@ lua::Property UiState::sQueueRandom{false, [](const lua::LuaValue& val) { sServices->track_queue().random(new_val); return true; }}; +lua::Property UiState::sQueueLoading{false}; lua::Property UiState::sVolumeCurrentPct{ 0, [](const lua::LuaValue& val) { @@ -424,7 +425,7 @@ void UiState::react(const system_fsm::BatteryStateChanged& ev) { } } -void UiState::react(const audio::QueueUpdate&) { +void UiState::react(const audio::QueueUpdate& update) { auto& queue = sServices->track_queue(); auto queue_size = queue.totalSize(); sQueueSize.setDirect(static_cast<int>(queue_size)); @@ -439,6 +440,12 @@ void UiState::react(const audio::QueueUpdate&) { sQueueRandom.setDirect(queue.random()); sQueueRepeat.setDirect(queue.repeat()); sQueueReplay.setDirect(queue.replay()); + + if (update.reason == audio::QueueUpdate::Reason::kBulkLoadingUpdate) { + sQueueLoading.setDirect(true); + } else { + sQueueLoading.setDirect(false); + } } void UiState::react(const audio::PlaybackUpdate& ev) { @@ -614,6 +621,7 @@ void Lua::entry() { {"replay", &sQueueReplay}, {"repeat_track", &sQueueRepeat}, {"random", &sQueueRandom}, + {"loading", &sQueueLoading}, }); registry.AddPropertyModule("volume", { |
