Explorar o código

fix(mobile): navigation history pop

Tienson Qin hai 3 semanas
pai
achega
636bf92832
Modificáronse 2 ficheiros con 10 adicións e 9 borrados
  1. 5 3
      src/main/frontend/components/page.cljs
  2. 5 6
      src/main/mobile/navigation.cljs

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

@@ -457,7 +457,7 @@
        "Set property"))]])
 
 (rum/defc db-page-title
-  [page {:keys [whiteboard-page? sidebar? container-id tag-dialog?]}]
+  [page {:keys [whiteboard-page? sidebar? journals? container-id tag-dialog?]}]
   (let [with-actions? (not config/publishing?)]
     [:div.ls-page-title.flex.flex-1.w-full.content.items-start.title
      {:class (when-not whiteboard-page? "title")
@@ -476,7 +476,7 @@
                          (state/get-current-repo)
                          (:db/id page)
                          :page)
-                        (util/mobile?)
+                        (and (util/mobile?) journals?)
                         (route-handler/redirect-to-page! (:block/uuid page))
                         :else
                         nil))))}
@@ -680,6 +680,7 @@
                    (db-page-title page
                                   {:whiteboard-page? whiteboard-page?
                                    :sidebar? sidebar?
+                                   :journals? journals?
                                    :container-id (:container-id state)
                                    :tag-dialog? tag-dialog?})
                    (page-title-cp page {:journal? journal?
@@ -771,7 +772,8 @@
                (when page-block
                  (when-not (or preview-or-sidebar? (:tag-dialog? option))
                    (if-let [page-uuid (and (not (:db/id page*))
-                                           (and page-name (not page-uuid?))
+                                           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))))))

+ 5 - 6
src/main/mobile/navigation.cljs

@@ -122,10 +122,6 @@
             (let [history (vec history)
                   last-path (:path (last history))]
               (case nav-type
-                "pop" (if (> (count history) 1)
-                        (vec (butlast history))
-                        history)
-
                 "replace" (if (seq history)
                             (conj (vec (butlast history)) entry)
                             [entry])
@@ -242,8 +238,11 @@
   (let [stack (current-stack)
         {:keys [history]} (get @stack-history stack)
         history (vec history)]
-    (when (> (count history) 1)
-      (let [new-history (subvec history 0 (dec (count history)))
+    (when (>= (count history) 1)
+      (let [root-history? (= (count history) 1)
+            new-history (if root-history?
+                          history
+                          (subvec history 0 (dec (count history))))
             {:keys [route-match]} (peek new-history)
             route-match   (or route-match (:route-match (stack-defaults stack)))
             route-name    (get-in route-match [:data :name])