fix: project reload on rebuild and syntax check now gives toast

This commit is contained in:
2026-07-19 12:07:10 +02:00
parent 422f71c8ad
commit 9dab0ca57e
11 changed files with 119 additions and 13 deletions

View File

@@ -647,6 +647,7 @@ impl BdsApp {
pub(super) fn handle_script_editor_msg(&mut self, msg: ScriptEditorMsg) -> Task<Message> {
let mut run_request = None;
let mut syntax_notification = None;
if let Some(tab_id) = self.active_tab.clone()
&& let Some(state) = self.script_editors.get_mut(&tab_id)
{
@@ -680,14 +681,20 @@ impl BdsApp {
return self.save_script_editor(&tab_id);
}
ScriptEditorMsg::CheckSyntax => {
if let Some(st) = self.script_editors.get_mut(&tab_id) {
match engine::script::validate_script_syntax(&st.content) {
Ok(()) => {
st.validation_error = None;
}
Err(e) => {
st.validation_error = Some(e);
}
match engine::script::validate_script_syntax(&state.content) {
Ok(()) => {
state.validation_error = None;
syntax_notification = Some((
ToastLevel::Success,
t(self.ui_locale, "editor.syntaxValid"),
));
}
Err(error) => {
state.validation_error = Some(error.clone());
syntax_notification = Some((
ToastLevel::Error,
tw(self.ui_locale, "editor.syntaxInvalid", &[("error", &error)]),
));
}
}
}
@@ -713,6 +720,9 @@ impl BdsApp {
tab.is_dirty = st.is_dirty;
}
}
if let Some((level, message)) = syntax_notification {
self.notify(level, &message);
}
if let Some((source, entrypoint, kind)) = run_request {
let offline_mode = self.offline_mode;
let app_handler = crate::platform::script_host::handler(

View File

@@ -213,6 +213,7 @@ impl BdsApp {
Message::ApplySiteValidation => self.apply_site_validation(),
Message::EngineTaskDone {
task_id,
operation,
label,
result,
} => {
@@ -222,6 +223,26 @@ impl BdsApp {
_ if cancelled => {}
Ok(detail) => {
self.task_manager.complete(task_id);
if operation == "engine.rebuildStarted" {
let refreshed = self.db.as_ref().and_then(|db| {
let id = &self.active_project.as_ref()?.id;
bds_core::db::queries::project::get_project_by_id(db.conn(), id)
.ok()
});
if let Some(project) = refreshed {
if let Some(cached) = self
.projects
.iter_mut()
.find(|cached| cached.id == project.id)
{
*cached = project.clone();
}
self.active_project = Some(project);
if self.settings_state.is_some() {
self.settings_state = Some(self.hydrate_settings_state());
}
}
}
self.notify(ToastLevel::Success, &format!("{label}: {detail}"));
}
Err(err) => {

View File

@@ -314,6 +314,7 @@ impl BdsApp {
},
move |result| Message::EngineTaskDone {
task_id,
operation: "engine.reindexStarted",
label: label_for_message.clone(),
result,
},
@@ -321,7 +322,7 @@ impl BdsApp {
}
/// Spawn a blocking engine operation on a background thread via TaskManager.
pub(super) fn spawn_engine_task<F>(&mut self, label_key: &str, work: F) -> Task<Message>
pub(super) fn spawn_engine_task<F>(&mut self, label_key: &'static str, work: F) -> Task<Message>
where
F: FnOnce(PathBuf, String, PathBuf, Arc<TaskManager>, TaskId) -> Result<String, String>
+ Send
@@ -332,7 +333,7 @@ impl BdsApp {
pub(super) fn spawn_grouped_engine_task<F>(
&mut self,
label_key: &str,
label_key: &'static str,
group_name: &str,
work: F,
) -> Task<Message>
@@ -346,7 +347,7 @@ impl BdsApp {
pub(super) fn spawn_engine_task_in_group<F>(
&mut self,
label_key: &str,
label_key: &'static str,
group_name: Option<&str>,
work: F,
) -> Task<Message>
@@ -391,6 +392,7 @@ impl BdsApp {
},
move |result| Message::EngineTaskDone {
task_id,
operation: label_key,
label: label_for_msg.clone(),
result,
},