Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

updates: show check results with craft-update's CheckResultDialog

aiongg91e97c92ddc5
diff --git a/Cargo.lock b/Cargo.lock
index 7703d3e33..62f084afc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1047,7 +1047,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 457a284d2..b5b4312ea 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,7 @@ craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "92d392c
# desktop. The `egui` feature adds `craft_window::decorate`. (craft-libs#217.)
craft-window = { git = "https://github.com/storytold/craft-libs", rev = "92d392cff132eaf53e13afff77f38b5c11b73aa0", features = ["egui"] }
# 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"] }
# internal
vectorcraft-geom = { path = "crates/geom" }
vectorcraft-color = { path = "crates/color" }
diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv
index 229fb2b66..d32d91503 100644
--- a/crates/ui-egui/src/i18n/bs.tsv
+++ b/crates/ui-egui/src/i18n/bs.tsv
@@ -5832,10 +5832,7 @@ swatch White, Black Bijela, crna
swatch Yellow Žuta
swatch Yellow Green Žuto-zelena
Check for Updates… Provjeri ažuriranja…
- Checking for updates… Provjera ažuriranja…
- Could not check for updates:\n{error} Nije moguće provjeriti ažuriranja:\n{error}
VectorCraft Updates VectorCraft ažuriranja
- VectorCraft {version} is currently the newest version available. VectorCraft {version} je trenutno najnovija dostupna verzija.
Preparing the image… Priprema slike…
Tracing the colors… Praćenje boja…
Units & Scale Jedinice i skala
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 7244a27c6..2542ac663 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -16,10 +16,7 @@
# names, OpenType, the built-in workspace names and the bracketed perspective grid preset names.
About VectorCraft VectorCraft について
Check for Updates… アップデートを確認…
- Checking for updates… アップデートを確認中…
- Could not check for updates:\n{error} アップデートを確認できませんでした:\n{error}
VectorCraft Updates VectorCraft のアップデート
- VectorCraft {version} is currently the newest version available. VectorCraft {version} は最新バージョンです。
All Scripts すべての文字
Anchors: アンカー:
Any Kind すべての種類
diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv
index 851441fee..3da858206 100644
--- a/crates/ui-egui/src/i18n/sv.tsv
+++ b/crates/ui-egui/src/i18n/sv.tsv
@@ -5875,8 +5875,6 @@ anchor Points: Punkter:
Arrow Scale: Pilskala:
Arrow Style: Pilstil:
Check for Updates… Sök efter uppdateringar…
- Checking for updates… Söker efter uppdateringar…
- Could not check for updates:\n{error} Det gick inte att söka efter uppdateringar:\n{error}
Dimension Lines Måttlinjer
Dimension Text Måttal
Extension Lines Måttgränslinjer
@@ -5898,7 +5896,6 @@ anchor Points: Punkter:
Tracing the colors… Vektoriserar färgerna…
Units & Scale Enheter & skala
VectorCraft Updates Uppdateringar för VectorCraft
- VectorCraft {version} is currently the newest version available. VectorCraft {version} är för närvarande den senaste tillgängliga versionen.
Yonroku-ban Yonroku-ban
@msg image '{key}' has no pixels and was left out bilden '{key}' har inga pixlar och utelämnades
@msg not an RTF file: it doesn't start with {\\rtf inte en RTF-fil: den börjar inte med {\\rtf
diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs
index ee9d09b71..a62a221c5 100644
--- a/crates/ui-egui/src/updates_ui.rs
+++ b/crates/ui-egui/src/updates_ui.rs
@@ -5,7 +5,9 @@ use serde_json::Value;
use crate::VectorcraftApp;
#[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"))]
@@ -18,7 +20,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<egui::Context>,
+ /// Whether the result of Help ▸ Check for Updates is in view.
pub(crate) manual_window_open: bool,
+ /// The web build has no updater; its window only says so.
+ #[cfg(target_arch = "wasm32")]
pub(crate) status_message: Option<String>,
}
@@ -34,6 +39,7 @@ impl Default for Runtime {
#[cfg(not(target_arch = "wasm32"))]
repaint: None,
manual_window_open: false,
+ #[cfg(target_arch = "wasm32")]
status_message: None,
}
}
@@ -51,6 +57,7 @@ pub(crate) fn check(app: &mut VectorcraftApp) -> Result<Value, String> {
#[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();
}
@@ -90,18 +97,25 @@ pub(crate) fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close),
Action::None => {}
}
- // The window answers Help ▸ Check for Updates, so it follows the updater's status.
+ // An available update goes to the prompt above, which replaces the result dialog.
let rt = &mut app.updates_rt;
- (rt.manual_window_open, rt.status_message) = match rt.updater.status() {
- Status::Idle => (false, None),
- Status::Checking => (true, Some(tl!("Checking for updates…").to_string())),
- Status::UpToDate => {
- (true, Some(tl!("VectorCraft {version} is currently the newest version available.").replace("{version}", env!("CARGO_PKG_VERSION"))))
+ if rt.manual_window_open && rt.updater.prompt_open() {
+ rt.manual_window_open = false;
+ }
+ 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,
+ CheckResultResponse::CheckAgain => rt.updater.check_now(ctx),
}
- Status::Failed(e) => (true, Some(tl!("Could not check for updates:\n{error}").replace("{error}", e))),
- };
+ }
+ // Closing the dialog dismisses the outcome it showed.
+ if !rt.manual_window_open {
+ rt.updater.dismiss_status();
+ }
}
+ #[cfg(target_arch = "wasm32")]
if app.updates_rt.manual_window_open {
let mut open = true;
egui::Window::new(tl!("VectorCraft Updates"))
@@ -123,17 +137,13 @@ pub(crate) fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
app.updates_rt.manual_window_open = false;
}
}
-
- // 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();
- }
}
#[cfg(test)]
mod tests {
use super::*;
+ #[cfg(not(target_arch = "wasm32"))]
+ use craft_update::updater::Status;
use vectorcraft_engine::Session;
#[test]