0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-18 13:04:38 -05:00

Improved go-to event impl.

This commit is contained in:
Andrey Antukh 2016-03-15 20:56:39 +02:00
parent fd2c27cdd6
commit 3e42e95151

View file

@ -161,16 +161,20 @@
"A shortcut event that redirects the user to the "A shortcut event that redirects the user to the
first page of the project." first page of the project."
([projectid] ([projectid]
(go-to projectid nil)) (reify
rs/WatchEvent
(-apply-watch [_ state]
(println "go-to" projectid)
(let [pages (stpr/project-pages state projectid)
pageid (:id (first pages))
params {:project-uuid projectid
:page-uuid pageid}]
(rx/of (r/navigate :workspace/page params))))))
([projectid pageid] ([projectid pageid]
(reify (reify
rs/EffectEvent rs/WatchEvent
(-apply-effect [_ state] (-apply-watch [_ state]
(if pageid (let [params {:project-uuid projectid
(rs/emit! (r/navigate :workspace/page {:project-uuid projectid :page-uuid pageid}]
:page-uuid pageid})) (rx/of (r/navigate :workspace/page params)))))))
(let [pages (stpr/project-pages state projectid)
pageid (:id (first pages))]
(println "selected" pageid "projectid" projectid)
(rs/emit! (r/navigate :workspace/page {:project-uuid projectid
:page-uuid pageid}))))))))