diff --git a/apps/effectcraft-web/src/app.rs b/apps/effectcraft-web/src/app.rs index 984db22fc..2882b16cf 100644 --- a/apps/effectcraft-web/src/app.rs +++ b/apps/effectcraft-web/src/app.rs @@ -215,14 +215,21 @@ fn install_hooks(app: &mut EffectcraftApp) { })); // Saving downloads the file: the chosen name is all a "save dialog" needs. A project (Save As, // Save a Copy) asks for the name, starting from the open project's (#2788): without asking, - // Save As would replace the open project's file; Cancel cancels. + // Save As would replace the open project's file; Cancel cancels. A name that is already in + // browser storage asks before replacing it, as the desktop's save dialogs do. app.hooks.pick_save = Some(Box::new(|name: &str| { let name = if name.is_empty() { "Untitled Project.ecproj" } else { name }; if !std::path::Path::new(name).extension().is_some_and(|e| e.eq_ignore_ascii_case("ecproj") || e.eq_ignore_ascii_case("ecprojx")) { return Some(files::path_for(name)); } - let typed = web_sys::window().and_then(|w| w.prompt_with_message_and_default("Save project as:", name).ok().flatten()); - crate::store::typed_save_name(name, typed).map(|n| files::path_for(&n)) + let window = web_sys::window()?; + let typed = window.prompt_with_message_and_default("Save project as:", name).ok().flatten(); + let typed = crate::store::typed_save_name(name, typed)?; + let path = files::path_for(&typed); + if files::get(&path).is_some() && !window.confirm_with_message(&format!("{typed} already exists. Replace it?")).unwrap_or(false) { + return None; + } + Some(path) })); app.hooks.audio_device = Some(Box::new(audio::open)); app.hooks.audio_devices = Some(Box::new(|| vec!["Browser default output".into()]));