mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 02:06:10 +02:00
🐛 Fix reactivity issue on workspace and file name change.
This commit is contained in:
parent
e61cdc500c
commit
84df0c431b
1 changed files with 25 additions and 18 deletions
|
@ -69,7 +69,6 @@
|
||||||
|
|
||||||
;; --- Initialize WebSocket
|
;; --- Initialize WebSocket
|
||||||
|
|
||||||
|
|
||||||
(s/def ::type keyword?)
|
(s/def ::type keyword?)
|
||||||
(s/def ::message
|
(s/def ::message
|
||||||
(s/keys :req-un [::type]))
|
(s/keys :req-un [::type]))
|
||||||
|
@ -189,8 +188,9 @@
|
||||||
:drawing-tool nil
|
:drawing-tool nil
|
||||||
:tooltip nil})
|
:tooltip nil})
|
||||||
|
|
||||||
(declare initialized)
|
(declare initialize-state)
|
||||||
(declare initialize-page)
|
(declare initialize-page)
|
||||||
|
(declare initialize-file)
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
"Initialize the workspace state."
|
"Initialize the workspace state."
|
||||||
|
@ -210,35 +210,32 @@
|
||||||
(rx/filter (ptk/type? ::dp/files-fetched) stream))
|
(rx/filter (ptk/type? ::dp/files-fetched) stream))
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/do #(reset! st/loader false))
|
(rx/do #(reset! st/loader false))
|
||||||
(rx/mapcat #(rx/of (initialized file-id)
|
(rx/mapcat #(rx/of (initialize-state file-id)
|
||||||
|
(initialize-file file-id)
|
||||||
(initialize-page page-id)
|
(initialize-page page-id)
|
||||||
#_(initialize-alignment page-id)))))
|
#_(initialize-alignment page-id)))))
|
||||||
(rx/merge
|
(rx/of (initialize-file file-id)
|
||||||
(rx/of (initialize-page page-id))))))))
|
(initialize-page page-id)))))))
|
||||||
|
|
||||||
(defn- initialized
|
(defn- initialize-state
|
||||||
[file-id]
|
[file-id]
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(ptk/reify ::initialized
|
(ptk/reify ::initialize-state
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [file (get-in state [:files file-id])
|
(let [local (assoc workspace-default :file-id file-id)]
|
||||||
local (assoc workspace-default :file-id file-id)]
|
|
||||||
(-> state
|
(-> state
|
||||||
(assoc :workspace-file file)
|
|
||||||
(assoc :workspace-layout default-layout)
|
(assoc :workspace-layout default-layout)
|
||||||
(assoc :workspace-local local))))))
|
(assoc :workspace-local local))))))
|
||||||
|
|
||||||
(defn finalize
|
(defn- initialize-file
|
||||||
[file-id page-id]
|
[file-id]
|
||||||
(us/assert ::us/uuid file-id)
|
(us/assert ::us/uuid file-id)
|
||||||
(us/assert ::us/uuid page-id)
|
(ptk/reify ::initialize-file
|
||||||
(ptk/reify ::finalize
|
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(dissoc state
|
(let [file (get-in state [:files file-id])]
|
||||||
:workspace-page
|
(assoc state :workspace-file file)))))
|
||||||
:workspace-data))))
|
|
||||||
|
|
||||||
(defn initialize-page
|
(defn initialize-page
|
||||||
[page-id]
|
[page-id]
|
||||||
|
@ -260,9 +257,19 @@
|
||||||
(rx/filter #(satisfies? IBatchedChange %))
|
(rx/filter #(satisfies? IBatchedChange %))
|
||||||
(rx/debounce 500)
|
(rx/debounce 500)
|
||||||
(rx/map (constantly commit-batched-changes))
|
(rx/map (constantly commit-batched-changes))
|
||||||
(rx/finalize #(prn "FINALIZE" %))
|
|
||||||
(rx/take-until stoper))))))
|
(rx/take-until stoper))))))
|
||||||
|
|
||||||
|
(defn finalize
|
||||||
|
[file-id page-id]
|
||||||
|
(us/assert ::us/uuid file-id)
|
||||||
|
(us/assert ::us/uuid page-id)
|
||||||
|
(ptk/reify ::finalize
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(dissoc state
|
||||||
|
:workspace-page
|
||||||
|
:workspace-data))))
|
||||||
|
|
||||||
;; --- Fetch Workspace Users
|
;; --- Fetch Workspace Users
|
||||||
|
|
||||||
(declare users-fetched)
|
(declare users-fetched)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue