Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Web: show the brush preset storage banner only while a change is unsaved (#4918)

Anton911881880dff
diff --git a/apps/photocraft-web/src/preset_bridge.rs b/apps/photocraft-web/src/preset_bridge.rs
index 6c9ef84ad..a7445bbc1 100644
--- a/apps/photocraft-web/src/preset_bridge.rs
+++ b/apps/photocraft-web/src/preset_bridge.rs
@@ -337,6 +337,7 @@ mod tests {
let b = Bridge::default();
b.unavailable("SecurityError".into());
let (mut s, _) = session(b.clone());
+ assert!(!b.unsaved(), "nothing is lost before the first change, so the web shell shows no banner");
import(&mut s);
assert!(s.tools.presets.iter().any(|p| p.name == "Browser seam brush"));
assert!(b.unsaved());
diff --git a/apps/photocraft-web/src/web.rs b/apps/photocraft-web/src/web.rs
index 8d7e8e082..a5c9d8a56 100644
--- a/apps/photocraft-web/src/web.rs
+++ b/apps/photocraft-web/src/web.rs
@@ -305,7 +305,12 @@ impl eframe::App for WebShell {
}
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
- if let Some(error) = self.presets.error() {
+ // Only while a preset change is unsaved. Storage the browser denies from the start (a
+ // sandboxed iframe, blocked site data) loses nothing until the first change, and that
+ // change brings the banner with the reason.
+ if self.presets.unsaved()
+ && let Some(error) = self.presets.error()
+ {
egui::Panel::top("browser_preset_storage").show(ui, |ui| {
let tokens = photocraft_ui_egui::theme::Tokens::for_kind(self.app.ui.theme);
// Put retry first so floating brush windows cannot cover the control.