fix toggling block marker if its reference is in editing

close https://github.com/logseq/logseq/issues/3806
This commit is contained in:
llcc
2022-02-25 11:28:31 +08:00
committed by Tienson Qin
parent dee179f5f5
commit ff001849ed

View File

@@ -765,20 +765,28 @@
content))
(defn check
[{:block/keys [marker content repeated?] :as block}]
[{:block/keys [marker content repeated? uuid] :as block}]
(let [new-content (string/replace-first content marker "DONE")
new-content (if repeated?
(update-timestamps-content! block content)
new-content)]
(save-block-if-changed! block new-content)))
(let [input-id (state/get-edit-input-id)]
(if (and input-id
(string/ends-with? input-id (str uuid)))
(state/set-edit-content! input-id new-content)
(save-block-if-changed! block new-content)))))
(defn uncheck
[{:block/keys [content] :as block}]
[{:block/keys [content uuid] :as block}]
(let [marker (if (= :now (state/get-preferred-workflow))
"LATER"
"TODO")
new-content (string/replace-first content "DONE" marker)]
(save-block-if-changed! block new-content)))
(let [input-id (state/get-edit-input-id)]
(if (and input-id
(string/ends-with? input-id (str uuid)))
(state/set-edit-content! input-id new-content)
(save-block-if-changed! block new-content)))))
(defn set-marker
[{:block/keys [marker content] :as block} new-marker]