Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

fix(tv): preserve playlist failure status

Samir Hossains60496ba9de47
diff --git a/src/tui/action.rs b/src/tui/action.rs
index a96f93b..1721b75 100644
--- a/src/tui/action.rs
+++ b/src/tui/action.rs
@@ -14,7 +14,7 @@ pub enum Action {
ToggleTvMode,
SwitchProvider(crate::providers::models::ProviderKind),
ShowTvConfig,
- TvChannelsLoaded(Vec<crate::providers::m3u::Channel>),
+ TvChannelsLoaded(Vec<crate::providers::m3u::Channel>, usize),
TvPlaylistAdd(String),
TvPlaylistRemove(usize),
TvReloadPlaylists,
diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rs
index 132a03b..8c43910 100644
--- a/src/tui/app/mod.rs
+++ b/src/tui/app/mod.rs
@@ -141,12 +141,9 @@ impl App {
}
}
}
- if failed > 0 {
- let _ = sender.send(Action::SetStatus(format!(
- "Error: {failed} playlist(s) failed to load."
- )));
- }
- sender.send(Action::TvChannelsLoaded(all_channels)).ok();
+ sender
+ .send(Action::TvChannelsLoaded(all_channels, failed))
+ .ok();
});
}
diff --git a/src/tui/app/tv.rs b/src/tui/app/tv.rs
index 7a1e8a8..6652c00 100644
--- a/src/tui/app/tv.rs
+++ b/src/tui/app/tv.rs
@@ -92,7 +92,7 @@ impl App {
self.state.tv_input_buffer.clear();
}
- Action::TvChannelsLoaded(channels) => {
+ Action::TvChannelsLoaded(channels, failed) => {
let mut seen = std::collections::HashSet::new();
self.state.tv_channels = channels
.into_iter()
@@ -108,19 +108,24 @@ impl App {
return None;
}
if self.state.tv_channels.is_empty() {
- self.state.set_status(
- "No TV channels found. Add a playlist (/config).".to_string(),
- 200,
- );
- } else {
- self.state.set_status(
+ let status = if failed > 0 {
format!(
- "{} TV channels imported from {} playlist(s).",
- self.state.tv_channels.len(),
- self.state.tv_playlists.len().max(1)
- ),
- 200,
+ "No TV channels found. {failed} playlist(s) failed to load. Add a playlist (/config)."
+ )
+ } else {
+ "No TV channels found. Add a playlist (/config).".to_string()
+ };
+ self.state.set_status(status, 200);
+ } else {
+ let mut status = format!(
+ "{} TV channels imported from {} playlist(s).",
+ self.state.tv_channels.len(),
+ self.state.tv_playlists.len().max(1)
);
+ if failed > 0 {
+ status.push_str(&format!(" {failed} playlist(s) failed to load."));
+ }
+ self.state.set_status(status, 200);
}
}
_ => return None,