Просмотр исходного кода

enhance(undo): use page-util/get-editing-page-id to get current

editing page
rcmerci 1 год назад
Родитель
Сommit
990376e38c

+ 0 - 12
src/main/frontend/components/right_sidebar.cljs

@@ -18,7 +18,6 @@
             [frontend.ui :as ui]
             [logseq.shui.ui :as shui]
             [frontend.util :as util]
-            [frontend.config :as config]
             [medley.core :as medley]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
@@ -104,17 +103,6 @@
                                                 {:default-collapsed? true})]) stack)
             {:default-collapsed? true})]))
 
-(rum/defc history < rum/reactive
-  []
-  ;; (let [state (undo-redo/get-state)
-  ;;       page-only-mode? (state/sub :history/page-only-mode?)]
-  ;;   [:div.ml-4
-  ;;    [:div.ml-3.font-bold (if page-only-mode? (t :right-side-bar/history-pageonly) (t :right-side-bar/history-global))]
-  ;;    [:div.p-4 [:.ml-4.mb-2
-  ;;               (history-stack (t :right-side-bar/history-undos) (rum/react (:undo-stack state)))
-  ;;               (history-stack (t :right-side-bar/history-redos) (rum/react (:redo-stack state)))]]])
-  )
-
 (defn build-sidebar-item
   [repo idx db-id block-type *db-id init-key]
   (case (keyword block-type)

+ 3 - 2
src/main/frontend/config.cljs

@@ -25,8 +25,9 @@
 
 (reset! state/publishing? publishing?)
 
-(goog-define TEST false)
-(def test? TEST)
+(comment
+  (goog-define TEST false)
+  (def test? TEST))
 
 (def ENABLE-FILE-SYNC-PRODUCTION false)
 

+ 3 - 7
src/main/frontend/handler/history.cljs

@@ -5,6 +5,7 @@
             [frontend.handler.route :as route-handler]
             [frontend.state :as state]
             [frontend.util :as util]
+            [frontend.util.page :as page-util]
             [goog.dom :as gdom]
             [promesa.core :as p]))
 
@@ -40,11 +41,7 @@
 (defn undo!
   [e]
   (when-let [repo (state/get-current-repo)]
-    ;; TODO:
-    ;; 1. :block/name will be non-unique, switch to other way to get current-page-uuid
-    ;; 2. (state/get-current-page) return wrong result when editing in right-sidebar
-    (when-let [current-page-uuid-str (some->> (state/get-current-page)
-                                              (vector :block/name)
+    (when-let [current-page-uuid-str (some->> (page-util/get-editing-page-id)
                                               db/entity
                                               :block/uuid
                                               str)]
@@ -61,8 +58,7 @@
 (defn redo!
   [e]
   (when-let [repo (state/get-current-repo)]
-    (when-let [current-page-uuid-str (some->> (state/get-current-page)
-                                              (vector :block/name)
+    (when-let [current-page-uuid-str (some->> (page-util/get-editing-page-id)
                                               db/entity
                                               :block/uuid
                                               str)]

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

@@ -25,12 +25,12 @@
   (history/restore-app-state! app-state))
 
 (defn invoke-hooks
-  [{:keys [_request-id tx-meta tx-data deleted-block-uuids affected-keys blocks] :as opts}]
+  [{:keys [_request-id tx-meta tx-data deleted-block-uuids affected-keys blocks]}]
   ;; (prn :debug
   ;;      :request-id request-id
   ;;      :tx-meta tx-meta
   ;;      :tx-data tx-data)
-  (let [{:keys [from-disk? new-graph? local-tx? undo? redo? initial-pages? end?]} tx-meta
+  (let [{:keys [from-disk? new-graph? undo? redo? initial-pages? end?]} tx-meta
         repo (state/get-current-repo)
         tx-report {:tx-meta tx-meta
                    :tx-data tx-data}