fix: don't save block when unmount caused by undo&&redo

pull/1697/head
Tienson Qin 2021-04-26 18:08:04 +08:00
parent a5cd457e76
commit da74ad31a5
2 changed files with 14 additions and 9 deletions

View File

@ -77,15 +77,16 @@
(notification/show! "Journal title can't be changed." :warning)
(let [new-name (if journal? (date/journal-title->default new-name) new-name)
new-path (if new-name
(if (and
new-name old-page-name
(= (string/lower-case new-name) (string/lower-case old-page-name)))
path
(page-handler/compute-new-file-path path new-name))
path)]
(if (and
new-name old-page-name
(= (string/lower-case new-name) (string/lower-case old-page-name)))
path
(page-handler/compute-new-file-path path new-name))
path)]
(file/alter-file (state/get-current-repo) new-path (string/trim value)
{:re-render-root? true})))))))
(when-not (contains? #{:insert :indent :outdent :auto-save} (state/get-editor-op))
;; TODO: ugly
(when-not (contains? #{:insert :indent :outdent :auto-save :undo :redo} (state/get-editor-op))
(editor-handler/save-block! (get-state) value))))
state)

View File

@ -36,12 +36,16 @@
(defn undo!
[e]
(util/stop e)
(state/set-editor-op! :undo)
(editor/save-current-block!)
(let [{:keys [editor-cursor]} (undo-redo/undo)]
(restore-cursor! editor-cursor)))
(restore-cursor! editor-cursor))
(state/set-editor-op! nil))
(defn redo!
[e]
(util/stop e)
(state/set-editor-op! :redo)
(let [{:keys [editor-cursor]} (undo-redo/redo)]
(restore-cursor! editor-cursor)))
(restore-cursor! editor-cursor))
(state/set-editor-op! nil))