mirror of https://github.com/logseq/logseq
fix: download graph
parent
472685fced
commit
82db2351fe
|
@ -247,7 +247,10 @@
|
|||
|
||||
(defn- with-write-transit-str
|
||||
[p]
|
||||
(p/chain p ldb/write-transit-str))
|
||||
(p/chain p
|
||||
(fn [result]
|
||||
(let [result (when-not (= result @worker-state/*state) result)]
|
||||
(ldb/write-transit-str result)))))
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(defclass DBWorker
|
||||
|
|
|
@ -8,61 +8,61 @@
|
|||
[frontend.util :as util]))
|
||||
|
||||
(defn invoke-hooks
|
||||
[{:keys [_request-id tx-meta tx-data deleted-block-uuids affected-keys blocks]}]
|
||||
[{:keys [_request-id repo tx-meta tx-data deleted-block-uuids affected-keys blocks]}]
|
||||
;; (prn :debug
|
||||
;; :request-id request-id
|
||||
;; :tx-meta tx-meta
|
||||
;; :tx-data tx-data)
|
||||
(let [{:keys [from-disk? new-graph? initial-pages? end?]} tx-meta
|
||||
repo (state/get-current-repo)
|
||||
tx-report {:tx-meta tx-meta
|
||||
:tx-data tx-data}
|
||||
conn (db/get-db repo false)]
|
||||
(cond
|
||||
initial-pages?
|
||||
(do
|
||||
(util/profile "transact initial-pages" (d/transact! conn tx-data tx-meta))
|
||||
(when end?
|
||||
(state/pub-event! [:init/commands])
|
||||
(react/clear-query-state!)
|
||||
(ui-handler/re-render-root!)))
|
||||
:tx-data tx-data}]
|
||||
(when (= repo (state/get-current-repo))
|
||||
(let [conn (db/get-db repo false)]
|
||||
(cond
|
||||
initial-pages?
|
||||
(do
|
||||
(util/profile "transact initial-pages" (d/transact! conn tx-data tx-meta))
|
||||
(when end?
|
||||
(state/pub-event! [:init/commands])
|
||||
(react/clear-query-state!)
|
||||
(ui-handler/re-render-root!)))
|
||||
|
||||
(or from-disk? new-graph?)
|
||||
(do
|
||||
(d/transact! conn tx-data tx-meta)
|
||||
(react/clear-query-state!)
|
||||
(ui-handler/re-render-root!))
|
||||
(or from-disk? new-graph?)
|
||||
(do
|
||||
(d/transact! conn tx-data tx-meta)
|
||||
(react/clear-query-state!)
|
||||
(ui-handler/re-render-root!))
|
||||
|
||||
:else
|
||||
(do
|
||||
(let [tx-data' (if (contains? #{:create-property-text-block :insert-blocks} (:outliner-op tx-meta))
|
||||
(let [update-blocks-fully-loaded (keep (fn [datom] (when (= :block/uuid (:a datom))
|
||||
{:db/id (:e datom)
|
||||
:block.temp/fully-loaded? true})) tx-data)]
|
||||
(concat update-blocks-fully-loaded tx-data))
|
||||
tx-data)]
|
||||
(d/transact! conn tx-data' tx-meta))
|
||||
:else
|
||||
(do
|
||||
(let [tx-data' (if (contains? #{:create-property-text-block :insert-blocks} (:outliner-op tx-meta))
|
||||
(let [update-blocks-fully-loaded (keep (fn [datom] (when (= :block/uuid (:a datom))
|
||||
{:db/id (:e datom)
|
||||
:block.temp/fully-loaded? true})) tx-data)]
|
||||
(concat update-blocks-fully-loaded tx-data))
|
||||
tx-data)]
|
||||
(d/transact! conn tx-data' tx-meta))
|
||||
|
||||
(when-not (:graph/importing @state/state)
|
||||
(when-not (:graph/importing @state/state)
|
||||
;; safe to edit the next block now since other blocks (e.g. prev editing block)
|
||||
;; has been saved to the db now
|
||||
(when-let [next-edit-block @(:editor/next-edit-block @state/state)]
|
||||
(let [{:keys [block pos]} next-edit-block]
|
||||
(editor-handler/edit-block! block pos)
|
||||
(state/set-state! :editor/next-edit-block nil)))
|
||||
(when-let [next-edit-block @(:editor/next-edit-block @state/state)]
|
||||
(let [{:keys [block pos]} next-edit-block]
|
||||
(editor-handler/edit-block! block pos)
|
||||
(state/set-state! :editor/next-edit-block nil)))
|
||||
|
||||
(react/refresh! repo affected-keys)
|
||||
(react/refresh! repo affected-keys)
|
||||
|
||||
(state/set-state! :editor/start-pos nil)
|
||||
(state/set-state! :editor/start-pos nil)
|
||||
|
||||
(when (and state/lsp-enabled?
|
||||
(seq blocks)
|
||||
(<= (count blocks) 1000))
|
||||
(state/pub-event! [:plugin/hook-db-tx
|
||||
{:blocks blocks
|
||||
:deleted-block-uuids deleted-block-uuids
|
||||
:tx-data (:tx-data tx-report)
|
||||
:tx-meta (:tx-meta tx-report)}])))))
|
||||
(when (and state/lsp-enabled?
|
||||
(seq blocks)
|
||||
(<= (count blocks) 1000))
|
||||
(state/pub-event! [:plugin/hook-db-tx
|
||||
{:blocks blocks
|
||||
:deleted-block-uuids deleted-block-uuids
|
||||
:tx-data (:tx-data tx-report)
|
||||
:tx-meta (:tx-meta tx-report)}])))))))
|
||||
|
||||
(when (= (:outliner-op tx-meta) :delete-page)
|
||||
(state/pub-event! [:page/deleted repo (:deleted-page tx-meta) (:file-path tx-meta) tx-meta]))
|
||||
|
|
|
@ -60,7 +60,7 @@ generate undo ops.")
|
|||
(let [{:keys [from-disk?]} tx-meta
|
||||
result (worker-pipeline/invoke-hooks repo conn tx-report (worker-state/get-context))
|
||||
tx-report' (:tx-report result)]
|
||||
(when result
|
||||
(when (and result (not (:rtc-download-graph? tx-meta)))
|
||||
(let [data (merge
|
||||
{:request-id (:request-id tx-meta)
|
||||
:repo repo
|
||||
|
@ -71,13 +71,13 @@ generate undo ops.")
|
|||
|
||||
(when-not from-disk?
|
||||
(p/do!
|
||||
(let [{:keys [blocks-to-remove-set blocks-to-add]} (search/sync-search-indice repo tx-report')
|
||||
^js wo (worker-state/get-worker-object)]
|
||||
(when wo
|
||||
(when (seq blocks-to-remove-set)
|
||||
(.search-delete-blocks wo repo (bean/->js blocks-to-remove-set)))
|
||||
(when (seq blocks-to-add)
|
||||
(.search-upsert-blocks wo repo (bean/->js blocks-to-add))))))))))
|
||||
(let [{:keys [blocks-to-remove-set blocks-to-add]} (search/sync-search-indice repo tx-report')
|
||||
^js wo (worker-state/get-worker-object)]
|
||||
(when wo
|
||||
(when (seq blocks-to-remove-set)
|
||||
(.search-delete-blocks wo repo (bean/->js blocks-to-remove-set)))
|
||||
(when (seq blocks-to-add)
|
||||
(.search-upsert-blocks wo repo (bean/->js blocks-to-add))))))))))
|
||||
|
||||
|
||||
(defn listen-db-changes!
|
||||
|
|
|
@ -247,4 +247,5 @@
|
|||
(op-mem-layer/update-graph-uuid! repo graph-uuid)
|
||||
(m/? (op-mem-layer/new-task--sync-to-idb repo))
|
||||
(m/? (c.m/await-promise (.storeMetadata worker-obj repo (pr-str {:graph/uuid graph-uuid}))))
|
||||
(worker-state/set-rtc-downloading-graph! false))))))
|
||||
(worker-state/set-rtc-downloading-graph! false)
|
||||
nil)))))
|
||||
|
|
Loading…
Reference in New Issue