From 43d7a5cec230fb714c0878aa57060875f5807a01 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 21 Feb 2016 20:31:49 +0200 Subject: [PATCH] Improve workspace common lenses. --- src/uxbox/ui/workspace/base.cljs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/uxbox/ui/workspace/base.cljs b/src/uxbox/ui/workspace/base.cljs index 9ced4cc50..a4e5cf65a 100644 --- a/src/uxbox/ui/workspace/base.cljs +++ b/src/uxbox/ui/workspace/base.cljs @@ -4,7 +4,7 @@ [cats.labs.lens :as l] [uxbox.rstore :as rs] [uxbox.state :as st] - [uxbox.data.projects :as dp] + [uxbox.state.project :as stpr] [uxbox.data.workspace :as dw] [uxbox.util.geom.point :as gpt] [uxbox.util.lens :as ul] @@ -16,17 +16,25 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def ^:static project-l - (as-> (ul/dep-in [:projects-by-id] [:workspace :project]) $ - (l/focus-atom $ st/state))) + (letfn [(getter [state] + (let [project (get-in state [:workspace :project])] + (get-in state [:projects-by-id project])))] + (as-> (ul/getter getter) $ + (l/focus-atom $ st/state)))) (def ^:static page-l - (as-> (ul/dep-in [:pages-by-id] [:workspace :page]) $ - (l/focus-atom $ st/state))) + (letfn [(getter [state] + (let [page (get-in state [:workspace :page])] + (get-in state [:pages-by-id page])))] + (as-> (ul/getter getter) $ + (l/focus-atom $ st/state)))) (def ^:static pages-l - (as-> (ul/getter #(let [pid (get-in % [:workspace :project])] - (dp/project-pages % pid))) $ - (l/focus-atom $ st/state))) + (letfn [(getter [state] + (let [project (get-in state [:workspace :project])] + (stpr/project-pages state project)))] + (as-> (ul/getter getter) $ + (l/focus-atom $ st/state)))) (def ^:static workspace-l (as-> (l/in [:workspace]) $