소스 검색

Merge pull request #182 from logseq/gyk/fix/zoom-out-to-page

fix(editor): zoom out to parent page instead of today's journal
Tienson Qin 5 년 전
부모
커밋
9938c7f277
1개의 변경된 파일16개의 추가작업 그리고 13개의 파일을 삭제
  1. 16 13
      src/main/frontend/handler/editor.cljs

+ 16 - 13
src/main/frontend/handler/editor.cljs

@@ -1206,19 +1206,22 @@
     (js/window.history.forward)))
 
 (defn zoom-out! []
-  (let [parent? (atom false)]
-    (when-let [page (state/get-current-page)]
-      (let [block-id (and
-                      (string? page)
-                      (util/uuid-string? page)
-                      (medley/uuid page))
-            block-parent (db/get-block-parent (state/get-current-repo) block-id)]
-        (when-let [id (:block/uuid block-parent)]
-          (route-handler/redirect! {:to :page
-                                    :path-params {:name (str id)}})
-          (reset! parent? true))))
-    (when-not @parent?
-      (route-handler/redirect-to-home!))))
+  (when-let [page (state/get-current-page)]
+    (let [block-id (and
+                    (string? page)
+                    (util/uuid-string? page)
+                    (medley/uuid page))
+          repo (state/get-current-repo)
+          block-parent (db/get-block-parent repo block-id)]
+      (if-let [id (:block/uuid block-parent)]
+        (route-handler/redirect! {:to :page
+                                  :path-params {:name (str id)}})
+        (let [page-id (-> (db/entity [:block/uuid block-id])
+                          :block/page
+                          :db/id)]
+          (when-let [page-name (:page/name (db/entity repo page-id))]
+            (route-handler/redirect! {:to :page
+                                      :path-params {:name page-name}})))))))
 
 (defn cut-block!
   [block-id]