0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 23:31:21 -05:00

Add select page history event.

This commit is contained in:
Andrey Antukh 2016-03-27 18:31:10 +03:00
parent e2ad20b376
commit b00420d457

View file

@ -210,3 +210,26 @@
(defn clean-page-history
[]
(CleanPageHistory.))
;; --- Select Page History
(defrecord SelectPageHistory [page history]
rs/UpdateEvent
(-apply-update [_ state]
(let [page (get-in state [:pages-by-id page])
page' (assoc page
:history true
:data (:data history)
:version (:version history))]
(-> state
(stpr/unpack-page page')
(assoc-in [:workspace :history :selected] (:id history))
(update-in [:workspace :history]
(fn [v]
(if (:current-version v)
v
(assoc v :current-version (:version page)))))))))
(defn select-page-history
[id history]
(SelectPageHistory. id history))