fix: refresh all rows on plugin install (fixes dependencies showing up as not installed)

This commit is contained in:
Gabriele Musco 2025-01-26 11:31:17 +01:00
parent 67e2ade501
commit 9bdda7d63d
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
2 changed files with 9 additions and 29 deletions

View file

@ -49,9 +49,8 @@ pub enum PluginStoreMsg {
Refresh,
/// called by Refresh
DoRefresh,
Install(Plugin, relm4::Sender<StoreRowModelMsg>),
InstallFromDetails(Plugin),
InstallDownload(Vec<Plugin>, relm4::Sender<StoreRowModelMsg>),
Install(Plugin),
InstallDownload(Vec<Plugin>),
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)

View file

@ -36,7 +36,7 @@ pub enum StoreRowModelMsg {
#[derive(Debug)]
pub enum StoreRowModelOutMsg {
Install(Plugin, relm4::Sender<StoreRowModelMsg>),
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);
}