diff --git a/src/downloader.rs b/src/downloader.rs index 8e53ffa..7ac9e18 100644 --- a/src/downloader.rs +++ b/src/downloader.rs @@ -168,10 +168,6 @@ impl Downloader { ]); cmd } - url => { - log::error!("Unknown or unsupported hostname '{:?}'", url); - return Ok(()); - } }; if log::max_level() < Level::Debug { diff --git a/src/ui/gui/components/side_nav/context_menu.rs b/src/ui/gui/components/side_nav/context_menu.rs index 9783d20..7bce72d 100644 --- a/src/ui/gui/components/side_nav/context_menu.rs +++ b/src/ui/gui/components/side_nav/context_menu.rs @@ -1,4 +1,4 @@ -use egui::{Color32, RichText, TextBuffer}; +use egui::{Color32, RichText}; use crate::ui::gui::{components::ComponentContextMenu, windows::{self, WindowIndex}}; @@ -15,14 +15,14 @@ impl ComponentContextMenu for ContextMenu { if ui.button("Download all").clicked() { let Some(playlist) = gui.manifest.get_playlist(playlist_name) else { - gui.throw_error(&format!("Playlist not found: {}", playlist_name)); + gui.throw_error(format!("Playlist not found: {}", playlist_name)); ui.close_menu(); return; }; for (song_name, song) in playlist.get_songs() { - if let Err(e) = gui.downloader.download_song_nb(&gui.cfg, &playlist_name, song_name, song, gui.manifest.get_format()) { - gui.throw_error(&format!("Could not download song: {e}")); + if let Err(e) = gui.downloader.download_song_nb(&gui.cfg, playlist_name, song_name, song, gui.manifest.get_format()) { + gui.throw_error(format!("Could not download song: {e}")); ui.close_menu(); return; } @@ -41,7 +41,11 @@ impl ComponentContextMenu for ContextMenu { } if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() { let w = gui.windows.get_window::(WindowIndex::Confirm); - w.set_message(&"side_nav_playlist_manifest_delete", &"This will delete the playlist from the manifest file. This is NOT reversible", &vec![playlist_name.clone()]); + w.set_message( + &"side_nav_playlist_manifest_delete", + &"This will delete the playlist from the manifest file. This is NOT reversible", + &[playlist_name.clone()] + ); gui.windows.open(WindowIndex::Confirm, true); ui.close_menu(); } diff --git a/src/ui/gui/components/side_nav/mod.rs b/src/ui/gui/components/side_nav/mod.rs index ccd9fd7..f7859fe 100644 --- a/src/ui/gui/components/side_nav/mod.rs +++ b/src/ui/gui/components/side_nav/mod.rs @@ -28,12 +28,11 @@ impl ComponentUi for SideNav { .context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &pname)); ui.horizontal(|ui| { - let text; - if gui.current_playlist == *pname { - text = RichText::new(&pname).color(tint); + let text = if gui.current_playlist == *pname { + RichText::new(&pname).color(tint) } else { - text = RichText::new(&pname); - } + RichText::new(&pname) + }; let button = Label::new(text).sense(Sense::click()).selectable(false); let button = ui.add(button); diff --git a/src/ui/gui/components/song_list/context_menu.rs b/src/ui/gui/components/song_list/context_menu.rs index d4fcdcd..b64892e 100644 --- a/src/ui/gui/components/song_list/context_menu.rs +++ b/src/ui/gui/components/song_list/context_menu.rs @@ -12,10 +12,10 @@ pub struct SongInfo { } impl SongInfo { - pub fn new(pname: &String, sname: &String, song: &Song) -> Self { + pub fn new(pname: &str, sname: &str, song: &Song) -> Self { Self { - pname: pname.clone(), - sname: sname.clone(), + pname: pname.to_string(), + sname: sname.to_string(), song: song.clone() } } @@ -83,7 +83,11 @@ impl ComponentContextMenu for ContextMenu { } if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() { let w = gui.windows.get_window::(WindowIndex::Confirm); - w.set_message(&"song_list_song_manifest_delete", &"This will delete the song from the manifest file. This is NOT reversible", &vec![data.playlist_name().clone(), data.song_name().clone()]); + w.set_message( + &"song_list_song_manifest_delete", + &"This will delete the song from the manifest file. This is NOT reversible", + &[data.playlist_name().clone(), data.song_name().clone()] + ); gui.windows.open(WindowIndex::Confirm, true); ui.close_menu(); ui.close_menu(); diff --git a/src/ui/gui/windows/confirm.rs b/src/ui/gui/windows/confirm.rs index a1622d3..1a14654 100644 --- a/src/ui/gui/windows/confirm.rs +++ b/src/ui/gui/windows/confirm.rs @@ -1,4 +1,4 @@ -use egui::{Color32, Label, RichText, TextBuffer}; +use egui::{Color32, Label, RichText}; use super::{State, Window}; @@ -41,10 +41,10 @@ impl Window for ConfirmW { } impl ConfirmW { - pub fn set_message(&mut self, new_id: &S, text: &S, data: &Vec) { + pub fn set_message(&mut self, new_id: &S, text: &S, data: &[String]) { self.text = text.to_string(); self.id = new_id.to_string(); - self.data = data.clone(); + self.data = data.to_vec(); } pub fn get_response(&self) -> (&String, &Option, &Vec) { (&self.id, &self.response, &self.data) diff --git a/src/ui/gui/windows/import_playlist.rs b/src/ui/gui/windows/import_playlist.rs index 3ed6df0..8c6249e 100644 --- a/src/ui/gui/windows/import_playlist.rs +++ b/src/ui/gui/windows/import_playlist.rs @@ -1,4 +1,4 @@ -use crate::manifest::song::{Song, SongType}; +use crate::manifest::song::SongType; use super::{State, Window}; @@ -9,8 +9,8 @@ pub struct GuiImportPlaylist { ed_type: SongType, ed_name: String, ed_url: String, - urls_to_add: Vec, - playlist_name: String, + //urls_to_add: Vec, + // playlist_name: String, } @@ -46,8 +46,8 @@ impl Window for GuiImportPlaylist { } }); - if let Some(url) = self.urls_to_add.pop() { - todo!(); + //if let Some(_) = self.urls_to_add.pop() { + // todo!(); //let client = reqwest::blocking::Client::new(); // let song_name = crate::crawler::spotify::get_song_name(&client, url.clone())?; @@ -57,7 +57,7 @@ impl Window for GuiImportPlaylist { // playlist.add_song(song_name, song); //} //let _ = state.manifest.save(None); - } + //} if save {