mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-25 06:11:36 +03:00
fix(ui): fixed background picture updating
This commit is contained in:
parent
7d080fcdf4
commit
5ae39efbac
5 changed files with 15 additions and 13 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -63,7 +63,7 @@ dependencies = [
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libadwaita",
|
"libadwaita",
|
||||||
"md5",
|
"md-5",
|
||||||
"relm4",
|
"relm4",
|
||||||
"rfd",
|
"rfd",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -1486,12 +1486,6 @@ dependencies = [
|
||||||
"md5-asm",
|
"md5-asm",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "md5"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "md5-asm"
|
name = "md5-asm"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
|
|
@ -33,4 +33,4 @@ lazy_static = "1.4.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
cached = { version = "0.42", features = ["proc_macro"] }
|
cached = { version = "0.42", features = ["proc_macro"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
md5 = "0.7"
|
md-5 = { version = "0.10", features = ["asm"] }
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use anime_launcher_sdk::anime_game_core::installer::downloader::Downloader;
|
use anime_launcher_sdk::anime_game_core::installer::downloader::Downloader;
|
||||||
use anime_launcher_sdk::anime_game_core::curl::fetch;
|
use anime_launcher_sdk::anime_game_core::curl::fetch;
|
||||||
|
|
||||||
|
use md5::{Md5, Digest};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Background {
|
pub struct Background {
|
||||||
pub uri: String,
|
pub uri: String,
|
||||||
|
@ -45,7 +47,7 @@ pub fn download_background() -> anyhow::Result<()> {
|
||||||
let info = get_background_info()?;
|
let info = get_background_info()?;
|
||||||
|
|
||||||
if crate::BACKGROUND_FILE.exists() {
|
if crate::BACKGROUND_FILE.exists() {
|
||||||
let hash = md5::compute(std::fs::read(crate::BACKGROUND_FILE.as_path())?);
|
let hash = Md5::digest(std::fs::read(crate::BACKGROUND_FILE.as_path())?);
|
||||||
|
|
||||||
if format!("{:x}", hash).to_lowercase() == info.hash {
|
if format!("{:x}", hash).to_lowercase() == info.hash {
|
||||||
tracing::debug!("Background picture is already downloaded. Skipping");
|
tracing::debug!("Background picture is already downloaded. Skipping");
|
||||||
|
@ -56,6 +58,8 @@ pub fn download_background() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let mut downloader = Downloader::new(info.uri)?;
|
let mut downloader = Downloader::new(info.uri)?;
|
||||||
|
|
||||||
|
downloader.continue_downloading = false;
|
||||||
|
|
||||||
if let Err(err) = downloader.download_to(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
|
if let Err(err) = downloader.download_to(crate::BACKGROUND_FILE.as_path(), |_, _| {}) {
|
||||||
let err: std::io::Error = err.into();
|
let err: std::io::Error = err.into();
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,11 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
main_window = adw::Window {
|
main_window = adw::Window {
|
||||||
set_title: Some("An Anime Game Launcher"),
|
#[watch]
|
||||||
|
set_title: match model.style {
|
||||||
|
LauncherStyle::Modern => Some("An Anime Game Launcher"),
|
||||||
|
LauncherStyle::Classic => Some("")
|
||||||
|
},
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
set_default_size: (
|
set_default_size: (
|
||||||
|
@ -551,7 +555,7 @@ impl SimpleComponent for App {
|
||||||
|
|
||||||
tracing::info!("Main window initialized");
|
tracing::info!("Main window initialized");
|
||||||
|
|
||||||
let download_picture = model.style == LauncherStyle::Classic && !KEEP_BACKGROUND_FILE.exists();
|
let download_picture = model.style == LauncherStyle::Classic;
|
||||||
|
|
||||||
// Initialize some heavy tasks
|
// Initialize some heavy tasks
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
|
|
|
@ -630,13 +630,13 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
if let Err(err) = package.delete_in(&config.game.path) {
|
if let Err(err) = package.delete_in(&config.game.path) {
|
||||||
tracing::error!("Failed to delete voice package: {:?}", package.locale());
|
tracing::error!("Failed to delete voice package: {:?}", package.locale());
|
||||||
|
|
||||||
sender.input(GeneralAppMsg::Toast {
|
sender.input(GeneralAppMsg::Toast {
|
||||||
title: tr("voice-package-deletion-error"),
|
title: tr("voice-package-deletion-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.input(GeneralAppMsg::SetVoicePackageSensitivity(index, true));
|
sender.input(GeneralAppMsg::SetVoicePackageSensitivity(index, true));
|
||||||
sender.output(PreferencesAppMsg::UpdateLauncherState);
|
sender.output(PreferencesAppMsg::UpdateLauncherState);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue