mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-02-18 00:02:06 +03:00
fix: fixed components related error on changing default path
This commit is contained in:
parent
9a0a327bc0
commit
b2ff2c585d
2 changed files with 91 additions and 82 deletions
|
@ -350,6 +350,19 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
if wine.is_downloaded_in(&config.game.wine.builds) {
|
if wine.is_downloaded_in(&config.game.wine.builds) {
|
||||||
tracing::info!("Wine already installed: {}", wine.name);
|
tracing::info!("Wine already installed: {}", wine.name);
|
||||||
|
|
||||||
|
let mut config = config::get().unwrap_or_default();
|
||||||
|
|
||||||
|
config.game.wine.selected = Some(wine.name);
|
||||||
|
|
||||||
|
if let Err(err) = config::update_raw(config) {
|
||||||
|
tracing::error!("Failed to update config: {err}");
|
||||||
|
|
||||||
|
sender.output(Self::Output::Toast {
|
||||||
|
title: tr("config-update-error"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sender.input(DownloadComponentsAppMsg::CreatePrefix);
|
sender.input(DownloadComponentsAppMsg::CreatePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +407,8 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
config.game.wine.selected = Some(wine.name.clone());
|
config.game.wine.selected = Some(wine.name.clone());
|
||||||
|
|
||||||
if let Err(err) = config::update_raw(config) {
|
if let Err(err) = config::update_raw(config) {
|
||||||
|
tracing::error!("Failed to update config: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("config-update-error"),
|
title: tr("config-update-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
|
|
|
@ -161,7 +161,7 @@ impl SimpleComponent for FirstRunApp {
|
||||||
toast_overlay,
|
toast_overlay,
|
||||||
carousel,
|
carousel,
|
||||||
|
|
||||||
loading: Some(None),
|
loading: None,
|
||||||
title: tr("welcome")
|
title: tr("welcome")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -172,70 +172,16 @@ impl SimpleComponent for FirstRunApp {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
MAIN_WINDOW = Some(widgets.window.clone());
|
MAIN_WINDOW = Some(widgets.window.clone());
|
||||||
|
|
||||||
|
crate::READY = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::info!("First run window initialized");
|
tracing::info!("First run window initialized. App is ready");
|
||||||
|
|
||||||
let components_sender = model.download_components.sender().clone();
|
|
||||||
|
|
||||||
// Initialize some heavy tasks
|
|
||||||
#[allow(unused_must_use)]
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
tracing::info!("Initializing heavy tasks");
|
|
||||||
|
|
||||||
// Update components index
|
|
||||||
|
|
||||||
sender.input(FirstRunAppMsg::SetLoadingStatus(Some(Some(tr("updating-components-index")))));
|
|
||||||
|
|
||||||
let components = ComponentsLoader::new(&CONFIG.components.path);
|
|
||||||
|
|
||||||
match components.is_sync(&CONFIG.components.servers) {
|
|
||||||
Ok(true) => (),
|
|
||||||
|
|
||||||
Ok(false) => {
|
|
||||||
for host in &CONFIG.components.servers {
|
|
||||||
match components.sync(host) {
|
|
||||||
Ok(true) => break,
|
|
||||||
Ok(false) => continue,
|
|
||||||
|
|
||||||
Err(err) => {
|
|
||||||
tracing::error!("Failed to sync components index");
|
|
||||||
|
|
||||||
sender.input(FirstRunAppMsg::Toast {
|
|
||||||
title: tr("components-index-sync-failed"),
|
|
||||||
description: Some(err.to_string())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(err) => {
|
|
||||||
tracing::error!("Failed to verify that components index synced");
|
|
||||||
|
|
||||||
sender.input(FirstRunAppMsg::Toast {
|
|
||||||
title: tr("components-index-verify-failed"),
|
|
||||||
description: Some(err.to_string())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update versions lists in download components page and hide status page
|
|
||||||
components_sender.send(DownloadComponentsAppMsg::UpdateVersionsLists);
|
|
||||||
sender.input(FirstRunAppMsg::SetLoadingStatus(None));
|
|
||||||
|
|
||||||
// Mark app as loaded
|
|
||||||
unsafe {
|
|
||||||
crate::READY = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!("App is ready");
|
|
||||||
});
|
|
||||||
|
|
||||||
ComponentParts { model, widgets } // will return soon
|
ComponentParts { model, widgets } // will return soon
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
|
fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
|
||||||
tracing::debug!("Called first run window event: {:?}", msg);
|
tracing::debug!("Called first run window event: {:?}", msg);
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
|
@ -268,6 +214,54 @@ impl SimpleComponent for FirstRunApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
FirstRunAppMsg::ScrollToDownloadComponents => {
|
FirstRunAppMsg::ScrollToDownloadComponents => {
|
||||||
|
// Update components index
|
||||||
|
sender.input(FirstRunAppMsg::SetLoadingStatus(Some(Some(tr("updating-components-index")))));
|
||||||
|
|
||||||
|
let components_sender = self.download_components.sender().clone();
|
||||||
|
let components = ComponentsLoader::new(&CONFIG.components.path);
|
||||||
|
|
||||||
|
#[allow(unused_must_use)]
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
match components.is_sync(&CONFIG.components.servers) {
|
||||||
|
Ok(true) => (),
|
||||||
|
|
||||||
|
Ok(false) => {
|
||||||
|
for host in &CONFIG.components.servers {
|
||||||
|
match components.sync(host) {
|
||||||
|
Ok(true) => break,
|
||||||
|
Ok(false) => continue,
|
||||||
|
|
||||||
|
Err(err) => {
|
||||||
|
tracing::error!("Failed to sync components index");
|
||||||
|
|
||||||
|
sender.input(FirstRunAppMsg::Toast {
|
||||||
|
title: tr("components-index-sync-failed"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(err) => {
|
||||||
|
tracing::error!("Failed to verify that components index synced");
|
||||||
|
|
||||||
|
sender.input(FirstRunAppMsg::Toast {
|
||||||
|
title: tr("components-index-verify-failed"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update versions lists in download components page
|
||||||
|
components_sender.send(DownloadComponentsAppMsg::UpdateVersionsLists);
|
||||||
|
|
||||||
|
// Hide status page
|
||||||
|
sender.input(FirstRunAppMsg::SetLoadingStatus(None));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scroll to download components page
|
||||||
|
// This will happen in background behind StatusPage
|
||||||
self.title = tr("download-components");
|
self.title = tr("download-components");
|
||||||
|
|
||||||
self.carousel.scroll_to(self.download_components.widget(), true);
|
self.carousel.scroll_to(self.download_components.widget(), true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue