Przeglądaj źródła

fix: navigate to parent or home page after deleting focused node

fixes https://github.com/logseq/db-test/issues/435
Tienson Qin 2 miesięcy temu
rodzic
commit
3888559b9d
1 zmienionych plików z 10 dodań i 2 usunięć
  1. 10 2
      src/main/frontend/modules/outliner/pipeline.cljs

+ 10 - 2
src/main/frontend/modules/outliner/pipeline.cljs

@@ -5,10 +5,12 @@
             [frontend.db :as db]
             [frontend.db.react :as react]
             [frontend.fs :as fs]
+            [frontend.handler.route :as route-handler]
             [frontend.handler.ui :as ui-handler]
             [frontend.state :as state]
             [frontend.util :as util]
-            [logseq.common.path :as path]))
+            [logseq.common.path :as path]
+            [logseq.db :as ldb]))
 
 (defn- update-editing-block-title-if-changed!
   [tx-data]
@@ -34,7 +36,13 @@
     (when (= repo (state/get-current-repo))
       (when (seq deleted-block-uuids)
         (let [ids (map (fn [id] (:db/id (db/entity [:block/uuid id]))) deleted-block-uuids)]
-          (state/sidebar-remove-deleted-block! ids)))
+          (state/sidebar-remove-deleted-block! ids))
+        (when-let [block-id (state/get-current-page)]
+          (when (contains? (set (map str deleted-block-uuids)) block-id)
+            (let [parent (:block/parent (ldb/get-page (db/get-db) block-id))]
+              (if parent
+                (route-handler/redirect-to-page! (:block/uuid parent))
+                (route-handler/redirect-to-home!))))))
 
       (when-let [conn (db/get-db repo false)]
         (cond