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"))