Browse Source

debug: collect insert block timeout errors

Tienson Qin 3 months ago
parent
commit
d0b433c82a
2 changed files with 15 additions and 9 deletions
  1. 13 7
      src/main/frontend/handler/editor.cljs
  2. 2 2
      src/main/mobile/init.cljs

+ 13 - 7
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]

+ 2 - 2
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"