mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 10:26:35 +00:00
refacotr(editor): reorder create-today-journal condition, avoid file reading
This commit is contained in:
@@ -836,19 +836,19 @@
|
||||
(config/get-file-extension format))
|
||||
repo-dir (config/get-repo-dir repo)
|
||||
template (state/get-default-journal-template)]
|
||||
(p/let [file-exists? (fs/file-exists? repo-dir file-rpath)
|
||||
file-content (when file-exists?
|
||||
(fs/read-file repo-dir file-rpath))]
|
||||
(when (and (db/page-empty? repo today-page)
|
||||
(or (not file-exists?)
|
||||
(and file-exists? (string/blank? file-content))))
|
||||
(create! title {:redirect? false
|
||||
:split-namespace? false
|
||||
:create-first-block? (not template)
|
||||
:journal? true})
|
||||
(state/pub-event! [:journal/insert-template today-page])
|
||||
(ui-handler/re-render-root!)
|
||||
(plugin-handler/hook-plugin-app :today-journal-created {:title today-page}))))))))
|
||||
(when (db/page-empty? repo today-page)
|
||||
(p/let [file-exists? (fs/file-exists? repo-dir file-rpath)
|
||||
file-content (when file-exists?
|
||||
(fs/read-file repo-dir file-rpath))]
|
||||
(when (or (not file-exists?)
|
||||
(and file-exists? (string/blank? file-content)))
|
||||
(create! title {:redirect? false
|
||||
:split-namespace? false
|
||||
:create-first-block? (not template)
|
||||
:journal? true})
|
||||
(state/pub-event! [:journal/insert-template today-page])
|
||||
(ui-handler/re-render-root!)
|
||||
(plugin-handler/hook-plugin-app :today-journal-created {:title today-page})))))))))
|
||||
|
||||
(defn open-today-in-sidebar
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user