From 86521bd189f7f4a732eff542ffc1406bab5a9e8a Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Sat, 28 Oct 2023 13:47:42 +0200 Subject: [PATCH] AMADEUS: Refresh a playlist when asking to show it --- amadeus/src/app.rs | 1 - amadeus/src/components/sidebar.rs | 5 +++++ amadeus/src/message.rs | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/amadeus/src/app.rs b/amadeus/src/app.rs index c2fcfea5..2d929548 100644 --- a/amadeus/src/app.rs +++ b/amadeus/src/app.rs @@ -409,7 +409,6 @@ impl Amadeus { ) -> Command<<Self as Application>::Message> { let cfg = self.connect_config.clone(); let store = self.kara_store.clone(); - log::error!("{req:?}"); match req { RefreshRequest::Playlists => Command::perform(get_playlists(cfg), |res| { res.map_err(|err| log::error!("{err}")) diff --git a/amadeus/src/components/sidebar.rs b/amadeus/src/components/sidebar.rs index 26c7ce98..8d44702d 100644 --- a/amadeus/src/components/sidebar.rs +++ b/amadeus/src/components/sidebar.rs @@ -37,8 +37,13 @@ pub enum Request { #[derive(Debug, Clone)] pub enum Message { + /// The list of playlists was scrolled. Scrolled(Viewport), + + /// Need to update the list of playlists. Playlists(Vec<Arc<str>>), + + /// Delete a specific playlist. DeletePlaylist(Arc<str>), } diff --git a/amadeus/src/message.rs b/amadeus/src/message.rs index a3ddca6d..d7356469 100644 --- a/amadeus/src/message.rs +++ b/amadeus/src/message.rs @@ -231,9 +231,12 @@ impl From<sidebar::Request> for Message { ShowDatabase => Message::MainPanelDisplay(MainPanel(mainpanel::Show::Database)), ShowHistory => Message::MainPanelDisplay(MainPanel(mainpanel::Show::History)), ShowSettings => Message::MainPanelDisplay(Config), - ShowPlaylist(x) => Message::MainPanelDisplay(MainPanel(mainpanel::Show::Playlist(x))), RefreshPlaylists => Message::RefreshRequest(RefreshRequest::Playlists), Scrolled(x) => Message::SidebarMessage(sidebar::Message::Scrolled(x)), + ShowPlaylist(x) => Message::from_iter([ + Message::RefreshRequest(RefreshRequest::Playlist(x.clone())), + Message::MainPanelDisplay(MainPanel(mainpanel::Show::Playlist(x))), + ]), } } } -- GitLab