From 57d92d291a2e1d490331c50835054e44bce707e7 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 31 Oct 2026 04:42:35 +0000 Subject: [PATCH] updates: show check results with craft-update's CheckResultDialog --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/ui-egui/locales/ar.toml | 3 -- crates/ui-egui/locales/bs.toml | 3 -- crates/ui-egui/locales/en.toml | 3 -- crates/ui-egui/locales/fi.toml | 3 -- crates/ui-egui/locales/ka.toml | 3 -- crates/ui-egui/locales/sv.toml | 3 -- crates/ui-egui/src/dialogs/updates_ui.rs | 35 ++++++++++++------------ 9 files changed, 20 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e61bce32..797f6498d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=04aa1703b32d299e54f78fcde4182f2b393a9116#04aa1703b32d299e54f78fcde4182f2b393a9116" +source = "git+https://github.com/storytold/craft-libs?rev=c5a1cbfb5f9049f9270955caffb5bee5997aebf7#c5a1cbfb5f9049f9270955caffb5bee5997aebf7" dependencies = [ "chrono", "dunce", diff --git a/Cargo.toml b/Cargo.toml index fe3059450..a560971a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-l # pull a second egui family version). craft-window = { git = "https://github.com/storytold/craft-libs", rev = "e11f9d9aebea5f6b8e74643c1ea1ed172ba5f545" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "04aa1703b32d299e54f78fcde4182f2b393a9116", features = ["egui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "c5a1cbfb5f9049f9270955caffb5bee5997aebf7", features = ["egui"] } # The suite's font store: exact lookup of a missing font in the pinned Google Fonts and Noto # indexes, and checksum-verified installs into the one folder every Craft app reads (craft-libs). craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "e11f9d9aebea5f6b8e74643c1ea1ed172ba5f545" } diff --git a/crates/ui-egui/locales/ar.toml b/crates/ui-egui/locales/ar.toml index 51ce2ab38..86a21e234 100644 --- a/crates/ui-egui/locales/ar.toml +++ b/crates/ui-egui/locales/ar.toml @@ -228,7 +228,6 @@ status = "draft — needs native review" "Check" = "تحقق" "Check for Updates" = "التحقق من التحديثات" "Check for updates…" = "التحقق من التحديثات…" -"Checking for updates…" = "جارٍ التحقق من التحديثات…" "Checking the fonts installed on this computer…" = "جارٍ فحص الخطوط المثبتة على هذا الحاسوب…" "Checking the server…" = "جارٍ التحقق من الخادم…" "Chevron" = "شارة زاوية" @@ -357,7 +356,6 @@ status = "draft — needs native review" "Copy {value}" = "نسخ {value}" "Corner radius" = "نصف قطر الزوايا" "Corner smoothing" = "تنعيم الزوايا" -"Could not check for updates:\n{error}" = "تعذر التحقق من التحديثات:\n{error}" "Couldn't download the variables" = "تعذر تنزيل المتغيرات" "Couldn't download {name}" = "تعذر تنزيل {name}" "Couldn't reach {server}: showing what this computer remembers." = "تعذر الاتصال بـ {server}؛ تُعرض البيانات المحفوظة على هذا الحاسوب." @@ -548,7 +546,6 @@ status = "draft — needs native review" "Fetching from the server…" = "جارٍ الجلب من الخادم…" "FigCraft couldn't open its window: {error}" = "تعذر على FigCraft فتح نافذته: {error}" "FigCraft doesn't support every feature of these files yet. The notes list what was left out or changed in the imported copy; the original file is unchanged." = "لا يدعم FigCraft جميع مزايا هذه الملفات بعد. تسرد الملاحظات ما أُهمل أو عُدّل في النسخة المستوردة؛ ويظل الملف الأصلي دون تغيير." -"FigCraft {version} is currently the newest version available." = "FigCraft {version} هو أحدث إصدار متاح حاليًا." "File" = "ملف" "File name" = "اسم الملف" "File not found" = "لم يُعثر على الملف" diff --git a/crates/ui-egui/locales/bs.toml b/crates/ui-egui/locales/bs.toml index efc380f58..67e0a14cd 100644 --- a/crates/ui-egui/locales/bs.toml +++ b/crates/ui-egui/locales/bs.toml @@ -228,7 +228,6 @@ status = "draft — needs native review" "Check for Updates" = "Provjeri ažuriranja" "Check for updates" = "Provjeri ažuriranja" "Check for updates…" = "Provjeri ažuriranja…" -"Checking for updates…" = "Provjera ažuriranja…" "Checking the fonts installed on this computer…" = "Provjera fontova instaliranih na ovom računaru…" "Checking the server…" = "Provjera servera…" "Chevron" = "Ševron" @@ -359,7 +358,6 @@ status = "draft — needs native review" "Copy {value}" = "Kopiraj {value}" "Corner radius" = "Radijus ugla" "Corner smoothing" = "Zaglađivanje uglova" -"Could not check for updates:\n{error}" = "Nije moguće provjeriti ažuriranja:\n{error}" "Couldn't download the variables" = "Nije moguće preuzeti varijable" "Couldn't download {name}" = "Nije moguće preuzeti {name}" "Couldn't reach {server}: showing what this computer remembers." = "Server {server} nije dostupan: prikazuje se ono što ovaj računar pamti." @@ -554,7 +552,6 @@ status = "draft — needs native review" "FigCraft couldn't open its window: {error}" = "FigCraft nije mogao otvoriti svoj prozor: {error}" "FigCraft doesn't support every feature of these files yet. The notes list what was left out or changed in the imported copy; the original file is unchanged." = "FigCraft još ne podržava sve mogućnosti ovih datoteka. Napomene navode šta je izostavljeno ili promijenjeno u uvezenoj kopiji; originalna datoteka je nepromijenjena." "FigCraft stopped because of an internal error." = "FigCraft je zaustavljen zbog interne greške." -"FigCraft {version} is currently the newest version available." = "FigCraft {version} je trenutno najnovija dostupna verzija." "File" = "Datoteka" "File name" = "Ime datoteke" "File not found" = "Datoteka nije pronađena" diff --git a/crates/ui-egui/locales/en.toml b/crates/ui-egui/locales/en.toml index 4a8781c10..ba567dd81 100644 --- a/crates/ui-egui/locales/en.toml +++ b/crates/ui-egui/locales/en.toml @@ -230,7 +230,6 @@ name = "English" "Check for Updates" = "Check for Updates" "Check for updates" = "Check for updates" "Check for updates…" = "Check for updates…" -"Checking for updates…" = "Checking for updates…" "Checking the fonts installed on this computer…" = "Checking the fonts installed on this computer…" "Checking the server…" = "Checking the server…" "Chevron" = "Chevron" @@ -364,7 +363,6 @@ name = "English" "Copy {value}" = "Copy {value}" "Corner radius" = "Corner radius" "Corner smoothing" = "Corner smoothing" -"Could not check for updates:\n{error}" = "Could not check for updates:\n{error}" "Couldn't download the variables" = "Couldn't download the variables" "Couldn't download {name}" = "Couldn't download {name}" "Couldn't reach {server}: showing what this computer remembers." = "Couldn't reach {server}: showing what this computer remembers." @@ -562,7 +560,6 @@ name = "English" "FigCraft couldn't open its window: {error}" = "FigCraft couldn't open its window: {error}" "FigCraft doesn't support every feature of these files yet. The notes list what was left out or changed in the imported copy; the original file is unchanged." = "FigCraft doesn't support every feature of these files yet. The notes list what was left out or changed in the imported copy; the original file is unchanged." "FigCraft stopped because of an internal error." = "FigCraft stopped because of an internal error." -"FigCraft {version} is currently the newest version available." = "FigCraft {version} is currently the newest version available." "File" = "File" "File name" = "File name" "File not found" = "File not found" diff --git a/crates/ui-egui/locales/fi.toml b/crates/ui-egui/locales/fi.toml index dff5adf9c..f181ba8a5 100644 --- a/crates/ui-egui/locales/fi.toml +++ b/crates/ui-egui/locales/fi.toml @@ -359,7 +359,6 @@ status = "draft — needs native review" "Copy {value}" = "Kopioi: {value}" "Corner radius" = "Kulman säde" "Corner smoothing" = "Kulman pehmennys" -"Could not check for updates:\n{error}" = "Päivityksiä ei voitu tarkistaa:\n{error}" "Couldn't download the variables" = "Muuttujia ei voitu ladata" "Couldn't download {name}" = "Kohdetta {name} ei voitu ladata" "Couldn't reach {server}: showing what this computer remembers." = "Palvelimeen {server} ei saatu yhteyttä. Näytetään tämän tietokoneen muistamat tiedot." @@ -557,7 +556,6 @@ status = "draft — needs native review" "FigCraft couldn't open its window: {error}" = "FigCraft ei voinut avata ikkunaansa: {error}" "FigCraft doesn't support every feature of these files yet. The notes list what was left out or changed in the imported copy; the original file is unchanged." = "FigCraft ei vielä tue näiden tiedostojen kaikkia ominaisuuksia. Huomautukset kertovat, mitä tuodusta kopiosta jätettiin pois tai muutettiin. Alkuperäinen tiedosto säilyy ennallaan." "FigCraft stopped because of an internal error." = "FigCraft pysähtyi sisäisen virheen vuoksi." -"FigCraft {version} is currently the newest version available." = "FigCraft {version} on tällä hetkellä uusin saatavilla oleva versio." "File" = "Tiedosto" "File name" = "Tiedostonimi" "File not found" = "Tiedostoa ei löydy" @@ -978,7 +976,6 @@ status = "draft — needs native review" "Not read yet" = "Ei vielä luettu" "Check for updates" = "Tarkista päivitykset" "Check for updates…" = "Tarkista päivitykset…" -"Checking for updates…" = "Tarkistetaan päivityksiä…" "Not checked yet" = "Ei vielä tarkistettu" "Someone who left" = "Joku, joka lähti" "Take the results off the board; they stay in the file" = "Poista tulokset taululta; ne jäävät tiedostoon" diff --git a/crates/ui-egui/locales/ka.toml b/crates/ui-egui/locales/ka.toml index 131aeca74..90dffe678 100644 --- a/crates/ui-egui/locales/ka.toml +++ b/crates/ui-egui/locales/ka.toml @@ -1883,19 +1883,16 @@ status = "draft — reviewed by a native speaker, awaiting a maintainer's approv "Best effort" = "მაქსიმალური მიახლოება" "Check for Updates" = "განახლებების შემოწმება" "Check for updates…" = "განახლებების შემოწმება…" -"Checking for updates…" = "განახლებების შემოწმება…" "Compatibility" = "თავსებადობა" "Dart constants for Flutter…" = "Dart-ის კონსტანტები Flutter-ისთვის…" "Copy effect" = "ეფექტის კოპირება" "Copy fill" = "შევსების კოპირება" "Copy stroke" = "კონტურის კოპირება" -"Could not check for updates:\n{error}" = "განახლებების შემოწმება ვერ მოხერხდა:\n{error}" "Couldn't download {name}" = "{name} ვერ ჩამოიტვირთა" "Don't show this again" = "აღარ აჩვენო" "Exact only" = "მხოლოდ ზუსტი" "Exported {name}; {n} kinds of content were changed or left out" = { one = "ექსპორტირებულია: {name}; შეცვლილი ან გამოტოვებული შიგთავსის სახეობა: {n}", other = "ექსპორტირებულია: {name}; შეცვლილი ან გამოტოვებული შიგთავსის სახეობა: {n}" } "Exported {n} files; some content was changed or left out" = { one = "ექსპორტირებულია ფაილი: {n}; ზოგი შიგთავსი შეიცვალა ან გამოტოვებულია", other = "ექსპორტირებულია ფაილი: {n}; ზოგი შიგთავსი შეიცვალა ან გამოტოვებულია" } -"FigCraft {version} is currently the newest version available." = "FigCraft {version} ამჟამად უახლესი ხელმისაწვდომი ვერსიაა." "Format" = "ფორმატი" "Ignore unsupported" = "მხარდაუჭერელის უგულებელყოფა" "Leaving the prototype" = "პროტოტიპიდან გასვლა" diff --git a/crates/ui-egui/locales/sv.toml b/crates/ui-egui/locales/sv.toml index dd3d35953..748518fff 100644 --- a/crates/ui-egui/locales/sv.toml +++ b/crates/ui-egui/locales/sv.toml @@ -227,7 +227,6 @@ name = "Svenska" "Check for Updates" = "Sök efter uppdateringar" "Check for updates" = "Sök efter uppdateringar" "Check for updates…" = "Sök efter uppdateringar…" -"Checking for updates…" = "Söker efter uppdateringar…" "Checking the fonts installed on this computer…" = "Kontrollerar vilka typsnitt som är installerade på den här datorn…" "Checking the server…" = "Kontrollerar servern…" "Chevron" = "Vinkel" @@ -361,7 +360,6 @@ name = "Svenska" "Copy {value}" = "Kopiera {value}" "Corner radius" = "Hörnradie" "Corner smoothing" = "Hörnutjämning" -"Could not check for updates:\n{error}" = "Det gick inte att söka efter uppdateringar:\n{error}" "Couldn't download the variables" = "Det gick inte att hämta variablerna" "Couldn't download {name}" = "Det gick inte att hämta {name}" "Couldn't reach {server}: showing what this computer remembers." = "Det gick inte att nå {server}: visar det som den här datorn minns." @@ -558,7 +556,6 @@ name = "Svenska" "FigCraft couldn't open its window: {error}" = "FigCraft kunde inte öppna sitt fönster: {error}" "FigCraft doesn't support every feature of these files yet. The notes list what was left out or changed in the imported copy; the original file is unchanged." = "FigCraft stöder ännu inte alla funktioner i de här filerna. Anteckningarna visar vad som utelämnades eller ändrades i den importerade kopian; originalfilen är oförändrad." "FigCraft stopped because of an internal error." = "FigCraft stoppades på grund av ett internt fel." -"FigCraft {version} is currently the newest version available." = "FigCraft {version} är den senaste tillgängliga versionen." "File" = "Fil" "File name" = "Filnamn" "File not found" = "Filen hittades inte" diff --git a/crates/ui-egui/src/dialogs/updates_ui.rs b/crates/ui-egui/src/dialogs/updates_ui.rs index b60bdc863..a7809b41f 100644 --- a/crates/ui-egui/src/dialogs/updates_ui.rs +++ b/crates/ui-egui/src/dialogs/updates_ui.rs @@ -4,7 +4,9 @@ use crate::FigApp; use crate::i18n::tr; #[cfg(not(target_arch = "wasm32"))] -use craft_update::updater::{Action, Status, Updater}; +use craft_update::updater::{Action, Updater}; +#[cfg(not(target_arch = "wasm32"))] +use craft_update::{CheckResultDialog, CheckResultResponse}; pub(crate) struct Runtime { #[cfg(not(target_arch = "wasm32"))] @@ -17,7 +19,10 @@ pub(crate) struct Runtime { /// The context of the last frame, to wake the UI when a check is queued from a menu callback. #[cfg(not(target_arch = "wasm32"))] repaint: Option, + /// The result dialog of a manual check is open. pub(crate) manual_window_open: bool, + /// The web build has no updater; its only result is that checks are unsupported. + #[cfg(target_arch = "wasm32")] pub(crate) status_message: Option, } @@ -33,6 +38,7 @@ impl Default for Runtime { #[cfg(not(target_arch = "wasm32"))] repaint: None, manual_window_open: false, + #[cfg(target_arch = "wasm32")] status_message: None, } } @@ -50,6 +56,7 @@ pub(crate) fn check(app: &mut FigApp) { #[cfg(not(target_arch = "wasm32"))] { app.updates_rt.check_requested = true; + app.updates_rt.manual_window_open = true; if let Some(ctx) = &app.updates_rt.repaint { ctx.request_repaint(); } @@ -88,18 +95,20 @@ pub(crate) fn show(app: &mut FigApp, ctx: &egui::Context) { Action::Close => ctx.send_viewport_cmd_to(egui::ViewportId::ROOT, egui::ViewportCommand::Close), Action::None => {} } - // The window answers Help ▸ Check for Updates, so it follows the updater's status. let rt = &mut app.updates_rt; - (rt.manual_window_open, rt.status_message) = match rt.updater.status() { - Status::Idle => (false, None), - Status::Checking => (true, None), - Status::UpToDate => { - (true, Some(tr("FigCraft {version} is currently the newest version available.").replace("{version}", env!("CARGO_PKG_VERSION")))) + if rt.manual_window_open { + match CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).show(ctx, rt.updater.status()) { + CheckResultResponse::None => {} + CheckResultResponse::Close => { + rt.manual_window_open = false; + rt.updater.dismiss_status(); + } + CheckResultResponse::CheckAgain => rt.check_requested = true, } - Status::Failed(e) => (true, Some(tr("Could not check for updates:\n{error}").replace("{error}", e))), - }; + } } + #[cfg(target_arch = "wasm32")] if app.updates_rt.manual_window_open { let mut open = true; let mut close = false; @@ -111,8 +120,6 @@ pub(crate) fn show(app: &mut FigApp, ctx: &egui::Context) { .show(ctx, |ui| { if let Some(msg) = &app.updates_rt.status_message { ui.label(msg); - } else { - ui.label(tr("Checking for updates…")); } ui.add_space(8.0); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { @@ -126,10 +133,4 @@ pub(crate) fn show(app: &mut FigApp, ctx: &egui::Context) { app.updates_rt.status_message = None; } } - - // Closing the window dismisses the outcome it showed. - #[cfg(not(target_arch = "wasm32"))] - if !app.updates_rt.manual_window_open { - app.updates_rt.updater.dismiss_status(); - } }