浏览代码

fix(mobile): can't close page modal

Tienson Qin 3 月之前
父节点
当前提交
62aa6b98b3
共有 3 个文件被更改,包括 18 次插入7 次删除
  1. 3 1
      src/main/frontend/components/page.cljs
  2. 12 4
      src/main/mobile/core.cljs
  3. 3 2
      src/main/mobile/state.cljs

+ 3 - 1
src/main/frontend/components/page.cljs

@@ -721,7 +721,9 @@
                (reset! *page (db/entity (:db/id page-block)))
                (when page-block
                  (when-not (or preview-or-sidebar? (:tag-dialog? option))
-                   (if-let [page-uuid (and (not (:db/id page*)) (not page-uuid?) (:block/uuid page-block))]
+                   (if-let [page-uuid (and (not (:db/id page*))
+                                           (and page-name (not page-uuid?))
+                                           (:block/uuid page-block))]
                      (route-handler/redirect-to-page! (str page-uuid) {:push false})
                      (route-handler/update-page-title-and-label! (state/get-route-match))))))
              (assoc state

+ 12 - 4
src/main/mobile/core.cljs

@@ -3,13 +3,16 @@
   (:require ["react-dom/client" :as rdc]
             [frontend.background-tasks]
             [frontend.components.page :as page]
+            [frontend.db.async :as db-async]
             [frontend.handler :as fhandler]
             [frontend.handler.db-based.rtc-background-tasks]
+            [frontend.state :as state]
             [frontend.util :as util]
             [mobile.components.app :as app]
             [mobile.events]
             [mobile.init :as init]
-            [mobile.state :as state]
+            [mobile.state :as mobile-state]
+            [promesa.core :as p]
             [reitit.frontend :as rf]
             [reitit.frontend.easy :as rfe]))
 
@@ -35,9 +38,14 @@
      (when (= :page (get-in route [:data :name]))
        (let [id-str (get-in route [:path-params :name])]
          (when (util/uuid-string? id-str)
-           (let [page-uuid (uuid id-str)]
-             (state/set-singleton-modal! {:open? true
-                                          :block {:block/uuid page-uuid}}))))))
+           (let [page-uuid (uuid id-str)
+                 repo (state/get-current-repo)]
+             (when (and repo page-uuid)
+               (p/let [entity (db-async/<get-block repo page-uuid
+                                                   {:children? false
+                                                    :skip-refresh? true})]
+                 (when entity
+                   (mobile-state/open-block-modal! entity)))))))))
 
    ;; set to false to enable HistoryAPI
    {:use-fragment true}))

+ 3 - 2
src/main/mobile/state.cljs

@@ -10,8 +10,9 @@
 (defn set-singleton-modal! [data] (reset! *singleton-modal data))
 (defn open-block-modal!
   [block]
-  (set-singleton-modal! {:open? true
-                         :block block}))
+  (when block
+    (set-singleton-modal! {:open? true
+                           :block block})))
 (defn use-singleton-modal [] (r/use-atom *singleton-modal))
 
 (defonce *popup-data (atom nil))