mirror of
https://github.com/penpot/penpot.git
synced 2025-07-04 19:07:17 +02:00
Move watch-page-changes func on top of history ns.
This commit is contained in:
parent
414b25242d
commit
b871217bb6
1 changed files with 20 additions and 17 deletions
|
@ -21,6 +21,26 @@
|
||||||
replace-by-id
|
replace-by-id
|
||||||
index-by)]))
|
index-by)]))
|
||||||
|
|
||||||
|
;; --- Watch Page Changes
|
||||||
|
|
||||||
|
(declare fetch-page-history)
|
||||||
|
(declare fetch-pinned-page-history)
|
||||||
|
|
||||||
|
(defn watch-page-changes
|
||||||
|
"A function that starts watching for `IPageUpdate`
|
||||||
|
events emited to the global event stream and just
|
||||||
|
reacts on them emiting an other event that just
|
||||||
|
persists the state of the page in an undo stack."
|
||||||
|
[]
|
||||||
|
(letfn [(on-value [id]
|
||||||
|
(rs/emit! (fetch-page-history id)
|
||||||
|
(fetch-pinned-page-history id)))]
|
||||||
|
(as-> rs/stream $
|
||||||
|
(rx/filter udp/page-synced? $)
|
||||||
|
(rx/delay 500 $)
|
||||||
|
(rx/map (comp :id :page) $)
|
||||||
|
(rx/on-value $ on-value))))
|
||||||
|
|
||||||
;; --- Pinned Page History Fetched
|
;; --- Pinned Page History Fetched
|
||||||
|
|
||||||
(declare update-history-index)
|
(declare update-history-index)
|
||||||
|
@ -89,23 +109,6 @@
|
||||||
([id params]
|
([id params]
|
||||||
(map->FetchPageHistory (assoc params :id id))))
|
(map->FetchPageHistory (assoc params :id id))))
|
||||||
|
|
||||||
;; --- Watch Page Changes
|
|
||||||
|
|
||||||
(defn watch-page-changes
|
|
||||||
"A function that starts watching for `IPageUpdate`
|
|
||||||
events emited to the global event stream and just
|
|
||||||
reacts on them emiting an other event that just
|
|
||||||
persists the state of the page in an undo stack."
|
|
||||||
[]
|
|
||||||
(letfn [(on-value [id]
|
|
||||||
(rs/emit! (fetch-page-history id)
|
|
||||||
(fetch-pinned-page-history id)))]
|
|
||||||
(as-> rs/stream $
|
|
||||||
(rx/filter udp/page-synced? $)
|
|
||||||
(rx/delay 500 $)
|
|
||||||
(rx/map (comp :id :page) $)
|
|
||||||
(rx/on-value $ on-value))))
|
|
||||||
|
|
||||||
;; --- Select Page History
|
;; --- Select Page History
|
||||||
|
|
||||||
(defrecord SelectPageHistory [version]
|
(defrecord SelectPageHistory [version]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue