From 71b43d644cab7717a5e27654841e92b0aeffb4d9 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sat, 6 Dec 2025 13:04:00 +0100 Subject: [PATCH] Show refreshing status during library scan - Add is_refreshing flag to AppState - Display 'Refreshing library...' in status panel during scan - Note: scan is currently blocking, message may be brief - Infrastructure ready for future async scanning --- src/main.rs | 2 ++ src/state/mod.rs | 2 ++ src/ui/mod.rs | 14 +++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index fe1aa0d..85080fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,12 +178,14 @@ async fn handle_key_event(state: &mut AppState, player: &mut player::Player, key } } KeyCode::Char('r') => { + state.is_refreshing = true; tracing::info!("Rescanning..."); let cache_dir = cache::get_cache_dir()?; let new_cache = scanner::scan_paths(&state.config.scan_paths.paths)?; new_cache.save(&cache_dir)?; state.cache = new_cache; state.refresh_flattened_items(); + state.is_refreshing = false; tracing::info!("Rescan complete"); } _ => {} diff --git a/src/state/mod.rs b/src/state/mod.rs index 6adb78c..3de97f7 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -26,6 +26,7 @@ pub struct AppState { pub marked_files: HashSet, pub playlist: Vec, pub playlist_index: usize, + pub is_refreshing: bool, } #[derive(Debug, Clone)] @@ -58,6 +59,7 @@ impl AppState { marked_files: HashSet::new(), playlist: Vec::new(), playlist_index: 0, + is_refreshing: false, } } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 03563ea..1d34aea 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -65,11 +65,15 @@ fn render_status_panel(frame: &mut Frame, state: &AppState, area: Rect) { ]) .split(area); - // Player state - let state_text = match state.player_state { - PlayerState::Stopped => "Stopped", - PlayerState::Playing => "Playing", - PlayerState::Paused => "Paused", + // Player state or refreshing status + let state_text = if state.is_refreshing { + "Refreshing library..." + } else { + match state.player_state { + PlayerState::Stopped => "Stopped", + PlayerState::Playing => "Playing", + PlayerState::Paused => "Paused", + } }; let state_widget = Paragraph::new(state_text) .block(Block::default().borders(Borders::ALL).title("Status"))