From d0b433c82a8461aded0870897c1edf76ff55b975 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 16 Sep 2025 19:39:52 +0800 Subject: [PATCH] debug: collect insert block timeout errors --- src/main/frontend/handler/editor.cljs | 20 +++++++++++++------- src/main/mobile/init.cljs | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 5ada3375df..653cd255e0 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -353,13 +353,19 @@ :block/name (util/page-name-sanity-lc (:block/title new-block))) (dissoc :block/page))) new-block)] - (ui-outliner-tx/transact! - {:outliner-op :insert-blocks} - (save-current-block! {:current-block current-block}) - (outliner-op/insert-blocks! [new-block'] current-block {:sibling? sibling? - :keep-uuid? keep-uuid? - :ordered-list? ordered-list? - :replace-empty-target? replace-empty-target?})))) + (-> + (ui-outliner-tx/transact! + {:outliner-op :insert-blocks} + (save-current-block! {:current-block current-block}) + (outliner-op/insert-blocks! [new-block'] current-block {:sibling? sibling? + :keep-uuid? keep-uuid? + :ordered-list? ordered-list? + :replace-empty-target? replace-empty-target?})) + (p/timeout 2000) + (p/catch (fn [error] + (js/console.error error) + (state/pub-event! [:capture-error {:error error + :payload {:type :insert-block-timeout}}])))))) (defn- block-self-alone-when-insert? [config uuid] diff --git a/src/main/mobile/init.cljs b/src/main/mobile/init.cljs index f4285f68d1..6be1e524ec 100644 --- a/src/main/mobile/init.cljs +++ b/src/main/mobile/init.cljs @@ -64,7 +64,6 @@ "NOTE: don't add more logic in this listener, use mobile-flows instead" [^js state] (println :debug :app-state-change-handler state (js/Date.)) - (reset! mobile-flows/*mobile-app-state (.-isActive state)) (when (state/get-current-repo) (let [is-active? (.-isActive state)] (if (not is-active?) @@ -79,7 +78,8 @@ 500) (p/catch (fn [error] (js/console.error error) - (js/window.location.reload))))))))) + (js/window.location.reload)))))))) + (reset! mobile-flows/*mobile-app-state (.-isActive state))) (defn- general-init "Initialize event listeners used by both iOS and Android"