From 9bdda7d63d7fd75e2c164366361eaba91bb9eee4 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Sun, 26 Jan 2025 11:31:17 +0100 Subject: [PATCH] fix: refresh all rows on plugin install (fixes dependencies showing up as not installed) --- src/ui/plugins/store.rs | 34 +++++++---------------------- src/ui/plugins/store_row_factory.rs | 4 +--- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/ui/plugins/store.rs b/src/ui/plugins/store.rs index e8fca91..73c10a8 100644 --- a/src/ui/plugins/store.rs +++ b/src/ui/plugins/store.rs @@ -49,9 +49,8 @@ pub enum PluginStoreMsg { Refresh, /// called by Refresh DoRefresh, - Install(Plugin, relm4::Sender), - InstallFromDetails(Plugin), - InstallDownload(Vec, relm4::Sender), + Install(Plugin), + InstallDownload(Vec), Remove(Plugin), SetEnabled(PluginStoreSignalSource, Plugin, bool), ShowDetails(usize), @@ -291,22 +290,7 @@ impl AsyncComponent for PluginStore { self.refresh_plugin_rows(); self.set_refreshing(false); } - Self::Input::InstallFromDetails(plugin) => { - if let Some(row) = self - .plugin_rows - .as_mut() - .unwrap() - .guard() - .iter() - .find(|row| row.is_some_and(|row| row.plugin.appid == plugin.appid)) - .flatten() - { - sender.input(Self::Input::Install(plugin, row.input_sender.clone())) - } else { - error!("could not find corresponding listbox row") - } - } - Self::Input::Install(plugin, row_sender) => { + Self::Input::Install(plugin) => { self.set_locked(true); let mut plugins = vec![plugin]; for dep in plugins[0].dependencies.clone().unwrap_or_default() { @@ -333,9 +317,9 @@ impl AsyncComponent for PluginStore { return; } } - sender.input(Self::Input::InstallDownload(plugins, row_sender)) + sender.input(Self::Input::InstallDownload(plugins)) } - Self::Input::InstallDownload(plugins, row_sender) => { + Self::Input::InstallDownload(plugins) => { for plugin in plugins { let mut plugin = plugin.clone(); match plugin.exec_url.as_ref() { @@ -382,7 +366,7 @@ impl AsyncComponent for PluginStore { ); } }; - row_sender.emit(StoreRowModelMsg::Refresh(true, false)); + self.refresh_plugin_rows(); self.details .emit(StoreDetailMsg::Refresh(plugin.appid, true, false)); } @@ -534,7 +518,7 @@ impl AsyncComponent for PluginStore { .launch(()) .forward(sender.input_sender(), move |msg| match msg { StoreDetailOutMsg::GoBack => Self::Input::ShowPluginList, - StoreDetailOutMsg::Install(plugin) => Self::Input::InstallFromDetails(plugin), + StoreDetailOutMsg::Install(plugin) => Self::Input::Install(plugin), StoreDetailOutMsg::Remove(plugin) => Self::Input::Remove(plugin), StoreDetailOutMsg::SetEnabled(plugin, enabled) => { Self::Input::SetEnabled(PluginStoreSignalSource::Detail, plugin, enabled) @@ -554,9 +538,7 @@ impl AsyncComponent for PluginStore { AsyncFactoryVecDeque::builder() .launch(widgets.listbox.clone()) .forward(sender.input_sender(), move |msg| match msg { - StoreRowModelOutMsg::Install(appid, row_sender) => { - Self::Input::Install(appid, row_sender) - } + StoreRowModelOutMsg::Install(appid) => Self::Input::Install(appid), StoreRowModelOutMsg::Remove(appid) => Self::Input::Remove(appid), StoreRowModelOutMsg::SetEnabled(plugin, enabled) => { Self::Input::SetEnabled(PluginStoreSignalSource::Row, plugin, enabled) diff --git a/src/ui/plugins/store_row_factory.rs b/src/ui/plugins/store_row_factory.rs index 3ea2629..72f9e02 100644 --- a/src/ui/plugins/store_row_factory.rs +++ b/src/ui/plugins/store_row_factory.rs @@ -36,7 +36,7 @@ pub enum StoreRowModelMsg { #[derive(Debug)] pub enum StoreRowModelOutMsg { - Install(Plugin, relm4::Sender), + Install(Plugin), Remove(Plugin), SetEnabled(Plugin, bool), } @@ -104,7 +104,6 @@ impl AsyncFactoryComponent for StoreRowModel { sender .output(Self::Output::Install( plugin.clone(), - sender.input_sender().clone() )) .expect(SENDER_IO_ERR_MSG); } @@ -142,7 +141,6 @@ impl AsyncFactoryComponent for StoreRowModel { sender .output(Self::Output::Install( plugin.clone(), - sender.input_sender().clone() )) .expect(SENDER_IO_ERR_MSG); }