Skip to content

Commit

Permalink
refacotr(editor): reorder create-today-journal condition, avoid file …
Browse files Browse the repository at this point in the history
…reading
  • Loading branch information
andelf committed Aug 24, 2023
1 parent 97a2027 commit ebc8e81
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main/frontend/handler/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
[]
Expand Down

0 comments on commit ebc8e81

Please sign in to comment.