mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Improve history handling on frontend.
This commit is contained in:
parent
691c359985
commit
94677f2f7e
11 changed files with 322 additions and 281 deletions
|
@ -9,21 +9,20 @@
|
|||
(:require [lentes.core :as l]
|
||||
[beicon.core :as rx]
|
||||
[uxbox.main.constants :as c]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.main.lenses :as ul]))
|
||||
[uxbox.main.store :as st]))
|
||||
|
||||
;; --- Helpers
|
||||
|
||||
(defn resolve-project
|
||||
"Retrieve the current project."
|
||||
[state]
|
||||
(let [id (l/focus ul/selected-project state)]
|
||||
(get-in state [:projects id])))
|
||||
(let [project-id (get-in state [:workspace :project])]
|
||||
(get-in state [:projects project-id])))
|
||||
|
||||
(defn resolve-page
|
||||
[state]
|
||||
(let [id (l/focus ul/selected-page state)]
|
||||
(get-in state [:pages id])))
|
||||
(let [page-id (get-in state [:workspace :page])]
|
||||
(get-in state [:pages page-id])))
|
||||
|
||||
(defn- resolve-project-pages
|
||||
[state]
|
||||
|
@ -34,13 +33,19 @@
|
|||
(sort-by get-order))))
|
||||
|
||||
(def workspace
|
||||
(l/derive ul/workspace st/state))
|
||||
(-> (l/key :workspace)
|
||||
(l/derive st/state)))
|
||||
|
||||
(def selected-project
|
||||
"Ref to the current selected project."
|
||||
(-> (l/lens resolve-project)
|
||||
(l/derive st/state)))
|
||||
|
||||
(def selected-project-id
|
||||
"Ref to the current selected project id."
|
||||
(-> (l/key :project)
|
||||
(l/derive selected-project)))
|
||||
|
||||
(def selected-project-pages
|
||||
(-> (l/lens resolve-project-pages)
|
||||
(l/derive st/state)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue