fix: try to address duplicated journals

related to https://github.com/logseq/logseq/issues/595
pull/645/head
Tienson Qin 2020-11-07 15:56:01 +08:00
parent c88c1ee685
commit 9488ee2e03
2 changed files with 15 additions and 12 deletions

View File

@ -1872,14 +1872,16 @@
(defn cloned?
[repo-url]
(->
(d/q '[:find ?cloned
:in $ ?repo-url
:where
[?repo :repo/url ?repo-url]
[?repo :repo/cloned? ?cloned]]
(get-conn repo-url) repo-url)
ffirst))
(when-let [conn (get-conn repo-url)]
(->
(d/q '[:find ?cloned
:in $ ?repo-url
:where
[?repo :repo/url ?repo-url]
[?repo :repo/cloned? ?cloned]]
conn
repo-url)
ffirst)))
(defn reset-config!
[repo-url content]

View File

@ -19,9 +19,10 @@
(js/setInterval (fn []
(state/set-today! (date/today))
(when-let [repo (state/get-current-repo)]
(let [today-page (string/lower-case (date/today))]
(when (empty? (db/get-page-blocks-no-cache repo today-page))
(repo-handler/create-today-journal-if-not-exists repo)))))
(when (db/cloned? repo)
(let [today-page (string/lower-case (date/today))]
(when (empty? (db/get-page-blocks-no-cache repo today-page))
(repo-handler/create-today-journal-if-not-exists repo))))))
1000))
(defn restore-and-setup!
@ -70,7 +71,7 @@
(or force?
(and (state/get-edit-input-id)
(> (- (util/time-ms) last-stored-at) (* 5 60 1000)) ; 5 minutes
)
)
(nil? (state/get-edit-input-id))))
(p/let [_ (repo-handler/persist-repo! repo)]
(state/update-repo-last-stored-at! repo)))))))