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