From 3eecbfef476292093948feeef1fdcaca96be6e0f Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 23 Jun 2025 17:08:29 +0800 Subject: [PATCH] fix: table crashes and disable add button on mobile --- src/main/frontend/components/page.cljs | 87 ++++++++++++++------------ 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index 9ad43117a8..386b061230 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -102,45 +102,46 @@ (rum/defc add-button [block {:keys [container-id] :as config*}] - (let [*ref (rum/use-ref nil) - has-children? (:block/_parent block) - page? (ldb/page? block) - opacity-class (if has-children? "opacity-0" "opacity-50") - config (dissoc config* :page)] - (when page? - [:div.ls-block.block-add-button.flex-1.flex-col.rounded-sm.cursor-text.transition-opacity.ease-in.duration-100.!py-0 - {:class opacity-class - :data-block-id (:db/id block) - :ref *ref - :on-click (fn [e] - (util/stop e) - (state/set-state! :editor/container-id container-id) - (editor-handler/api-insert-new-block! "" (merge config - {:block-uuid (:block/uuid block)}))) - :on-mouse-over (fn [] - (let [ref (rum/deref *ref) - prev-block (util/get-prev-block-non-collapsed (rum/deref *ref) {:up-down? true})] - (cond - (and prev-block (dom/has-class? prev-block "is-blank")) - (dom/add-class! ref "opacity-0") - (and prev-block has-children?) - (dom/add-class! ref "opacity-50") - :else - (dom/add-class! ref "opacity-100")))) - :on-mouse-leave #(do - (dom/remove-class! (rum/deref *ref) "opacity-50") - (dom/remove-class! (rum/deref *ref) "opacity-100")) - :on-key-down (fn [e] - (util/stop e) - (when (= "Enter" (util/ekey e)) - (state/set-state! :editor/container-id container-id) - (editor-handler/api-insert-new-block! "" (merge config block)))) - :tab-index 0} - [:div.flex.flex-row - [:div.flex.items-center {:style {:height 28 - :margin-left (if (util/mobile?) 0 22)}} - [:span.bullet-container - [:span.bullet]]]]]))) + (when-not (util/capacitor-new?) + (let [*ref (rum/use-ref nil) + has-children? (:block/_parent block) + page? (ldb/page? block) + opacity-class (if has-children? "opacity-0" "opacity-50") + config (dissoc config* :page)] + (when page? + [:div.ls-block.block-add-button.flex-1.flex-col.rounded-sm.cursor-text.transition-opacity.ease-in.duration-100.!py-0 + {:class opacity-class + :data-block-id (:db/id block) + :ref *ref + :on-click (fn [e] + (util/stop e) + (state/set-state! :editor/container-id container-id) + (editor-handler/api-insert-new-block! "" (merge config + {:block-uuid (:block/uuid block)}))) + :on-mouse-over (fn [] + (let [ref (rum/deref *ref) + prev-block (util/get-prev-block-non-collapsed (rum/deref *ref) {:up-down? true})] + (cond + (and prev-block (dom/has-class? prev-block "is-blank")) + (dom/add-class! ref "opacity-0") + (and prev-block has-children?) + (dom/add-class! ref "opacity-50") + :else + (dom/add-class! ref "opacity-100")))) + :on-mouse-leave #(do + (dom/remove-class! (rum/deref *ref) "opacity-50") + (dom/remove-class! (rum/deref *ref) "opacity-100")) + :on-key-down (fn [e] + (util/stop e) + (when (= "Enter" (util/ekey e)) + (state/set-state! :editor/container-id container-id) + (editor-handler/api-insert-new-block! "" (merge config block)))) + :tab-index 0} + [:div.flex.flex-row + [:div.flex.items-center {:style {:height 28 + :margin-left (if (util/mobile?) 0 22)}} + [:span.bullet-container + [:span.bullet]]]]])))) (rum/defcs page-blocks-cp < rum/reactive db-mixins/query {:will-mount (fn [state] @@ -577,6 +578,8 @@ (rum/local nil ::current-page) (rum/local false ::objects-ready?) [state {:keys [repo page preview? sidebar? tag-dialog? linked-refs? unlinked-refs? config] :as option}] + (when (nil? page) + (js/console.trace)) (let [current-repo (state/sub :git/current-repo) *objects-ready? (::objects-ready? state) config (assoc config :*objects-ready? *objects-ready?) @@ -587,6 +590,7 @@ objects-ready? (if (or class-page? property-page?) (rum/react *objects-ready?) true) + _ (prn :debug :page page :option option) title (:block/title page) journal? (db/journal-page? title) db-based? (config/db-based-graph? repo) @@ -705,10 +709,9 @@ *loading? (atom true) page (db/get-page page-id-uuid-or-name) *page (atom page)] - (when (:block.temp/load-status page) (reset! *loading? false)) (p/let [page-block (db-async/