fix: don't create journal's file when it was initialized by a template

pull/6962/head^2
Tienson Qin 2022-10-12 13:11:49 +08:00
parent 21ff600c21
commit 8b0f83d3ab
2 changed files with 13 additions and 9 deletions

View File

@ -2017,7 +2017,8 @@
(when-let [db-id (if (integer? db-id)
db-id
(:db/id (db-model/get-template-by-name (name db-id))))]
(let [repo (state/get-current-repo)
(let [journal? (:block/journal? target)
repo (state/get-current-repo)
target (or target (state/get-edit-block))
block (db/entity db-id)
format (:block/format block)
@ -2060,12 +2061,14 @@
:else
true)]
(outliner-tx/transact!
{:outliner-op :insert-blocks}
(save-current-block!)
(let [result (outliner-core/insert-blocks! blocks'
target
(assoc opts :sibling? sibling?'))]
(edit-last-block-after-inserted! result))))))))
{:outliner-op :insert-blocks
:created-from-journal-template? journal?}
(save-current-block!)
(let [result (outliner-core/insert-blocks! blocks'
target
(assoc opts
:sibling? sibling?'))]
(edit-last-block-after-inserted! result))))))))
(defn template-on-chosen-handler
[element-id]

View File

@ -9,8 +9,9 @@
[clojure.set :as set]))
(defn updated-page-hook
[_tx-report page]
(file/sync-to-file page))
[tx-report page]
(when-not (get-in tx-report [:tx-meta :created-from-journal-template?])
(file/sync-to-file page)))
;; TODO: it'll be great if we can calculate the :block/path-refs before any
;; outliner transaction, this way we can group together the real outliner tx