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

editing page
pull/11293/head
rcmerci 2024-04-11 14:37:37 +08:00
parent 53970880d3
commit 990376e38c
4 changed files with 8 additions and 23 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)]

View File

@ -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}