mirror of https://github.com/logseq/logseq
fix: changes not refreshed immediately
parent
4f577114fa
commit
17f3b9c0d8
|
@ -13,7 +13,8 @@
|
|||
[frontend.encrypt :as encrypt]
|
||||
[frontend.db.model :as model]
|
||||
[frontend.handler.editor :as editor]
|
||||
[frontend.handler.extract :as extract]))
|
||||
[frontend.handler.extract :as extract]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- set-missing-block-ids!
|
||||
[content]
|
||||
|
@ -36,8 +37,8 @@
|
|||
(cond
|
||||
(= "add" type)
|
||||
(when-not (db/file-exists? repo path)
|
||||
(let [_ (file-handler/alter-file repo path content {:re-render-root? true
|
||||
:from-disk? true})]
|
||||
(p/let [_ (file-handler/alter-file repo path content {:re-render-root? true
|
||||
:from-disk? true})]
|
||||
(set-missing-block-ids! content)
|
||||
(db/set-file-last-modified-at! repo path mtime)
|
||||
;; return nil, otherwise the entire db will be transfered by ipc
|
||||
|
@ -50,8 +51,8 @@
|
|||
(and (= "change" type)
|
||||
(when-let [last-modified-at (db/get-file-last-modified-at repo path)]
|
||||
(> mtime last-modified-at)))
|
||||
(let [_ (file-handler/alter-file repo path content {:re-render-root? true
|
||||
:from-disk? true})]
|
||||
(p/let [_ (file-handler/alter-file repo path content {:re-render-root? true
|
||||
:from-disk? true})]
|
||||
(set-missing-block-ids! content)
|
||||
(db/set-file-last-modified-at! repo path mtime)
|
||||
nil)
|
||||
|
|
|
@ -169,27 +169,27 @@
|
|||
write-file! (if from-disk?
|
||||
#(p/resolved nil)
|
||||
#(fs/write-file! repo (config/get-repo-dir repo) path content (when original-content {:old-content original-content})))]
|
||||
(if reset?
|
||||
(do
|
||||
(when-let [page-id (db/get-file-page-id path)]
|
||||
(db/transact! repo
|
||||
[[:db/retract page-id :block/alias]
|
||||
[:db/retract page-id :block/tags]]))
|
||||
(reset-file! repo path content))
|
||||
(db/set-file-content! repo path content))
|
||||
(util/p-handle (write-file!)
|
||||
(fn [_]
|
||||
(when (= path (config/get-config-path repo))
|
||||
(restore-config! repo true))
|
||||
(when (= path (config/get-custom-css-path repo))
|
||||
(ui-handler/add-style-if-exists!))
|
||||
(when re-render-root? (ui-handler/re-render-root!))
|
||||
;; (when (and add-history? original-content)
|
||||
;; (history/add-history! repo [[path original-content content]]))
|
||||
)
|
||||
(fn [error]
|
||||
(println "Write file failed, path: " path ", content: " content)
|
||||
(log/error :write/failed error)))))
|
||||
(p/let [_ (if reset?
|
||||
(do
|
||||
(when-let [page-id (db/get-file-page-id path)]
|
||||
(db/transact! repo
|
||||
[[:db/retract page-id :block/alias]
|
||||
[:db/retract page-id :block/tags]]))
|
||||
(reset-file! repo path content))
|
||||
(db/set-file-content! repo path content))]
|
||||
(util/p-handle (write-file!)
|
||||
(fn [_]
|
||||
(when (= path (config/get-config-path repo))
|
||||
(restore-config! repo true))
|
||||
(when (= path (config/get-custom-css-path repo))
|
||||
(ui-handler/add-style-if-exists!))
|
||||
(when re-render-root? (ui-handler/re-render-root!))
|
||||
;; (when (and add-history? original-content)
|
||||
;; (history/add-history! repo [[path original-content content]]))
|
||||
)
|
||||
(fn [error]
|
||||
(println "Write file failed, path: " path ", content: " content)
|
||||
(log/error :write/failed error))))))
|
||||
|
||||
(defn set-file-content!
|
||||
[repo path new-content]
|
||||
|
|
Loading…
Reference in New Issue