fix: redirect to the new page when page property title changed

pull/2489/head
Tienson Qin 2021-07-30 20:49:26 +08:00
parent c87258c4e9
commit 55074dec1c
2 changed files with 13 additions and 1 deletions

View File

@ -348,7 +348,15 @@
(when refresh?
(let [opts {:key :block/change
:data [block]}]
(db/refresh! repo opts)))))
(db/refresh! repo opts)))
;; page title changed
(when-let [title (get-in block [:block/properties :title])]
(when-let [old-title (:block/name (db/entity (:db/id (:block/page block))))]
(when (and (:block/pre-block? block)
(not (string/blank? title))
(not= (string/lower-case title) old-title))
(state/pub-event! [:page/title-property-changed old-title title]))))))
(repo-handler/push-if-auto-enabled! repo)))

View File

@ -9,6 +9,7 @@
[frontend.handler.notification :as notification]
[frontend.handler.common :as common-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.page :as page-handler]
[frontend.components.encryption :as encryption]
[frontend.fs.nfs :as nfs]
[frontend.db.conn :as conn]
@ -133,6 +134,9 @@
(defmethod handle :modal/show-cards [_]
(state/set-modal! srs/global-cards))
(defmethod handle :page/title-property-changed [[_ old-title new-title]]
(page-handler/rename! old-title new-title))
(defmethod handle :after-db-restore [[_ repos]]
(mapv (fn [{url :url} repo]
;; compare :ast/version