mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 19:26:10 +02:00
Properly select the first page on workspace first load after dashboard.
This commit is contained in:
parent
aba35dee61
commit
f33fdc58a6
2 changed files with 22 additions and 2 deletions
|
@ -147,6 +147,9 @@
|
||||||
;; --- Pages Fetched
|
;; --- Pages Fetched
|
||||||
|
|
||||||
(deftype PagesFetched [pages]
|
(deftype PagesFetched [pages]
|
||||||
|
IDeref
|
||||||
|
(-deref [_] pages)
|
||||||
|
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(as-> state $
|
(as-> state $
|
||||||
|
|
|
@ -205,14 +205,31 @@
|
||||||
|
|
||||||
;; --- Go To & Go To Page
|
;; --- Go To & Go To Page
|
||||||
|
|
||||||
|
(deftype GoToFirstPage [pages]
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [[page & rest] (sort-by #(get-in % [:metadata :order]) pages)
|
||||||
|
params {:project (:project page)
|
||||||
|
:page (:id page)}]
|
||||||
|
(rx/of (rt/navigate :workspace/page params)))))
|
||||||
|
|
||||||
|
(defn go-to-first-page
|
||||||
|
[pages]
|
||||||
|
(GoToFirstPage. pages))
|
||||||
|
|
||||||
(defrecord GoTo [project-id]
|
(defrecord GoTo [project-id]
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [page-id (get-in state [:projects project-id :page-id])
|
(let [page-id (get-in state [:projects project-id :page-id])
|
||||||
params {:project project-id
|
params {:project project-id
|
||||||
:page page-id}]
|
:page page-id}]
|
||||||
(rx/of (udp/fetch-pages project-id)
|
(rx/merge
|
||||||
(rt/navigate :workspace/page params)))))
|
(rx/of (udp/fetch-pages project-id))
|
||||||
|
(->> stream
|
||||||
|
(rx/filter udp/pages-fetched?)
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/map deref)
|
||||||
|
(rx/map go-to-first-page))))))
|
||||||
|
|
||||||
(defrecord GoToPage [project-id page-id]
|
(defrecord GoToPage [project-id page-id]
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue