fix: Disabling journals not working

close #2646, #2665
pull/2664/head^2
Tienson Qin 2021-08-18 23:39:01 +08:00
parent 13dea5ebdd
commit a97b4fedea
1 changed files with 25 additions and 24 deletions

View File

@ -612,28 +612,29 @@
(defn create-today-journal!
[]
(state/set-today! (date/today))
(when-let [repo (state/get-current-repo)]
(when (or (db/cloned? repo)
(and (or (config/local-db? repo)
(= "local" repo))
;; config file exists
(let [path (config/get-config-path)]
(db/get-file path))))
(let [title (date/today)
today-page (string/lower-case title)
template (state/get-default-journal-template)]
(when (db/page-empty? repo today-page)
(create! title {:redirect? false
:split-namespace? false
:create-first-block? (not template)
:journal? true})
(when template
(let [page (db/pull [:block/name today-page])]
(editor-handler/insert-template!
nil
template
{:get-pos-fn (fn []
[page false false false])
:page-block page})
(ui-handler/re-render-root!))))))))
(when (state/enable-journals? repo)
(state/set-today! (date/today))
(when (or (db/cloned? repo)
(and (or (config/local-db? repo)
(= "local" repo))
;; config file exists
(let [path (config/get-config-path)]
(db/get-file path))))
(let [title (date/today)
today-page (string/lower-case title)
template (state/get-default-journal-template)]
(when (db/page-empty? repo today-page)
(create! title {:redirect? false
:split-namespace? false
:create-first-block? (not template)
:journal? true})
(when template
(let [page (db/pull [:block/name today-page])]
(editor-handler/insert-template!
nil
template
{:get-pos-fn (fn []
[page false false false])
:page-block page})
(ui-handler/re-render-root!)))))))))