mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix(timestamp): remove old SCHEDULED/DEADLINE timestamp
When using `date-picker` to update the SCHEDULED/DEADLINE timestamp by clicking an existing one, logseq will add a new timestamp instead of updating the old one. This patch fixs this issue.
This commit is contained in:
@@ -1006,7 +1006,8 @@
|
||||
(when-let [block (db/pull [:block/uuid block-id])]
|
||||
(let [{:block/keys [content scheduled deadline format]} block
|
||||
content (or (state/get-edit-content) content)
|
||||
new-content (text/add-timestamp content key value)]
|
||||
new-content (-> (text/remove-timestamp content key)
|
||||
(text/add-timestamp key value))]
|
||||
(when (not= content new-content)
|
||||
(if-let [input-id (state/get-edit-input-id)]
|
||||
(state/set-edit-content! input-id new-content)
|
||||
|
||||
@@ -240,3 +240,13 @@
|
||||
new-line
|
||||
(rest new-lines))))]
|
||||
(string/join "\n" new-lines)))
|
||||
|
||||
(defn remove-timestamp
|
||||
[content key]
|
||||
(let [lines (string/split-lines content)
|
||||
new-lines (filter (fn [line]
|
||||
(not (string/starts-with? (string/lower-case line) key)))
|
||||
lines)]
|
||||
(println "new-lines" new-lines)
|
||||
(string/join "\n" new-lines)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user