fix(admin): cap tiptap editor ready-polling at 100 attempts

Replace infinite loop with bounded for-loop (100 × 100ms = 10s max).
On timeout the skeleton overlay is dismissed so the user can still
interact with the form instead of being stuck forever.
This commit is contained in:
xfy 2026-06-03 10:34:06 +08:00
parent 61ae3abbc2
commit 09060e12c0

View File

@ -57,7 +57,7 @@ pub fn Write() -> Element {
#[cfg(target_arch = "wasm32")]
{
wasm_bindgen_futures::spawn_local(async move {
loop {
for _ in 0..100 {
if let Ok(promise_val) = js_sys::eval("new Promise(r => setTimeout(r, 100))") {
if let Ok(promise) = promise_val.dyn_into::<js_sys::Promise>() {
let _ = wasm_bindgen_futures::JsFuture::from(promise).await;
@ -66,10 +66,11 @@ pub fn Write() -> Element {
if let Ok(ready) = js_sys::eval("window.__tiptap_ready") {
if ready.as_bool().unwrap_or(false) {
loading.set(false);
break;
return;
}
}
}
loading.set(false);
});
}
#[cfg(not(target_arch = "wasm32"))]