mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
Improve page persistence mechanism.
This commit is contained in:
parent
f7e4e18a28
commit
b00992881c
1 changed files with 16 additions and 7 deletions
|
@ -242,6 +242,10 @@
|
|||
(s/def ::metadata-persisted-event
|
||||
(s/keys :req-un [::id ::version]))
|
||||
|
||||
(defn metadata-persisted?
|
||||
[v]
|
||||
(instance? MetadataPersisted. v))
|
||||
|
||||
(defn metadata-persisted
|
||||
[{:keys [id] :as data}]
|
||||
{:pre [(us/valid? ::metadata-persisted-event data)]}
|
||||
|
@ -399,16 +403,21 @@
|
|||
(rx/take 1))]
|
||||
(rx/merge
|
||||
(->> stream
|
||||
(rx/take-until stopper)
|
||||
(rx/filter #(not= @rlocks/lock :shape/resize))
|
||||
(rx/filter #(satisfies? IPageUpdate %))
|
||||
(rx/debounce 1000)
|
||||
(rx/map #(persist-page id)))
|
||||
(->> stream
|
||||
(rx/take-until stopper)
|
||||
(rx/filter #(satisfies? IMetadataUpdate %))
|
||||
(rx/debounce 1000)
|
||||
(rx/map #(persist-metadata id)))))))
|
||||
(rx/mapcat #(rx/merge (rx/of (persist-page id))
|
||||
(->> (rx/filter page-persisted? stream)
|
||||
(rx/take 1)
|
||||
(rx/ignore)))))
|
||||
(->> stream
|
||||
(rx/filter #(satisfies? IMetadataUpdate %))
|
||||
(rx/take-until stopper)
|
||||
(rx/debounce 1000)
|
||||
(rx/mapcat #(rx/merge (rx/of (persist-metadata id))
|
||||
(->> (rx/filter metadata-persisted? stream)
|
||||
(rx/take 1)
|
||||
(rx/ignore)))))))))
|
||||
|
||||
(defn watch-page-changes
|
||||
[id]
|
||||
|
|
Loading…
Add table
Reference in a new issue