fix: transact today's journal tx-data iff it doesn't exists yet

This commit is contained in:
Tienson Qin
2024-01-09 16:32:43 +08:00
parent 4da564cd0b
commit 48125c3edc
4 changed files with 24 additions and 13 deletions

View File

@@ -77,7 +77,8 @@
[frontend.persist-db.browser :as db-browser]
[frontend.db.rtc.debug-ui :as rtc-debug-ui]
[frontend.modules.outliner.pipeline :as pipeline]
[electron.ipc :as ipc]))
[electron.ipc :as ipc]
[frontend.date :as date]))
;; TODO: should we move all events here?
@@ -347,7 +348,9 @@
(page-handler/rename! old-title new-title))
(defmethod handle :page/create [[_ page-name opts]]
(page-handler/create! page-name opts))
(if (= page-name (date/today))
(page-handler/create-today-journal!)
(page-handler/create! page-name opts)))
(defmethod handle :page/deleted [[_ repo page-name file-path]]
(page-common-handler/after-page-deleted! repo page-name file-path))

View File

@@ -286,10 +286,12 @@
(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}))]
:journal? true
:today-journal? true})
(js/setTimeout #(do
(state/pub-event! [:journal/insert-template today-page])
(ui-handler/re-render-root!)
(plugin-handler/hook-plugin-app :today-journal-created {:title today-page})) 100))]
(when (db/page-empty? repo today-page)
(if (config/db-based-graph? repo)
(let [page-exists (db/get-page today-page)]