fix: remove infinite loop in submit_action effects

This commit is contained in:
alphafetus committed 2026-01-16 10:07:19 -05:00
1 parent 9ebab0689a
commit 95b69a36a8
7 files changed
+54 -52

No files matched your search

+20 -13
View File
@@ -490,25 +490,32 @@ fn ScholarshipForm(
});
};
Effect::new(move || {
match submit_action.value().get() {
Some(Ok(_)) => toasts.toast(
Toast::new()
Effect::watch(
move || submit_action.value().get(),
move |value, _, _| {
log!("Running submit_action effect");
let Some(result) = value else {
return;
};
let toast = match result {
Ok(_) => Toast::new()
.id(uuid::Uuid::new_v4())
.header("Submission Successful")
.msg("You can go back or continue editing your responses.")
),
Some(Err(err)) => toasts.toast(
Toast::new()
.msg("You can go back or continue editing your responses."),
Err(err) => Toast::new()
.id(uuid::Uuid::new_v4())
.header("Submission Failed")
.msg(err.to_string())
),
_ => {}
}
};
submit_action.clear();
});
untrack(move || {
submit_action.clear();
toasts.toast(toast);
});
},
false
);
//#endregion