mirror of
https://github.com/logseq/logseq.git
synced 2026-05-28 22:49:53 +00:00
fix: create new graph result in NoModificationAllowedError
This commit is contained in:
@@ -141,7 +141,7 @@
|
||||
(defrecord InBrowser []
|
||||
protocol/PersistentDB
|
||||
(<new [_this repo opts]
|
||||
(state/<invoke-db-worker :thread-api/create-or-open-db repo opts))
|
||||
(state/<invoke-db-worker :thread-api/create-or-open-db repo (assoc opts :create-graph? true)))
|
||||
|
||||
(<list-db [_this]
|
||||
(-> (state/<invoke-db-worker :thread-api/list-db)
|
||||
|
||||
@@ -380,7 +380,8 @@
|
||||
(create-graph-for-rtc-test repo init-tx-data tx-data)
|
||||
(c.m/<?
|
||||
(p/do!
|
||||
((@thread-api/*thread-apis :thread-api/create-or-open-db) repo {:close-other-db? false})
|
||||
((@thread-api/*thread-apis :thread-api/create-or-open-db) repo {:close-other-db? false
|
||||
:create-graph? true})
|
||||
((@thread-api/*thread-apis :thread-api/export-db) repo)
|
||||
((@thread-api/*thread-apis :thread-api/transact)
|
||||
repo init-tx-data
|
||||
|
||||
@@ -323,21 +323,31 @@
|
||||
#js {:get (fn [target method]
|
||||
(assert (identical? "remoteInvoke" method) method)
|
||||
(fn [args]
|
||||
(if @*master-client?
|
||||
(<apply-target-f! target method args)
|
||||
(let [request-id (next-request-id)
|
||||
client-channel (ensure-client-channel client-id service-name)]
|
||||
(p/create
|
||||
(fn [resolve-fn reject-fn]
|
||||
(vswap! *requests-in-flight assoc request-id {:method method
|
||||
:args args
|
||||
:resolve-fn resolve-fn
|
||||
:reject-fn reject-fn})
|
||||
(.postMessage client-channel (bean/->js
|
||||
{:id request-id
|
||||
:type "request"
|
||||
:method method
|
||||
:args args}))))))))})
|
||||
(let [new-graph? (when (= "thread-api/create-or-open-db" (first args))
|
||||
(:create-graph? (second (ldb/read-transit-str (last args)))))]
|
||||
(cond
|
||||
new-graph?
|
||||
(do
|
||||
(reset! *master-client? true)
|
||||
(<apply-target-f! target method args))
|
||||
|
||||
@*master-client?
|
||||
(<apply-target-f! target method args)
|
||||
|
||||
:else
|
||||
(let [request-id (next-request-id)
|
||||
client-channel (ensure-client-channel client-id service-name)]
|
||||
(p/create
|
||||
(fn [resolve-fn reject-fn]
|
||||
(vswap! *requests-in-flight assoc request-id {:method method
|
||||
:args args
|
||||
:resolve-fn resolve-fn
|
||||
:reject-fn reject-fn})
|
||||
(.postMessage client-channel (bean/->js
|
||||
{:id request-id
|
||||
:type "request"
|
||||
:method method
|
||||
:args args})))))))))})
|
||||
:status status}))
|
||||
|
||||
(defn broadcast-to-clients!
|
||||
|
||||
Reference in New Issue
Block a user