mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 01:01:30 -05:00
Remove o replace apropriately the transfer-state func on components.
This commit is contained in:
parent
5dc4dec1e0
commit
8b32c69377
12 changed files with 21 additions and 53 deletions
|
@ -139,7 +139,7 @@
|
||||||
(rs/emit! (dd/initialize :dashboard/icons))
|
(rs/emit! (dd/initialize :dashboard/icons))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(defn icons-page-transfer-state
|
(defn icons-page-did-remount
|
||||||
[old-state state]
|
[old-state state]
|
||||||
(rs/emit! (dd/initialize :dashboard/icons))
|
(rs/emit! (dd/initialize :dashboard/icons))
|
||||||
state)
|
state)
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
(mx/component
|
(mx/component
|
||||||
{:render icons-page-render
|
{:render icons-page-render
|
||||||
:will-mount icons-page-will-mount
|
:will-mount icons-page-will-mount
|
||||||
:transfer-state icons-page-transfer-state
|
:did-remount icons-page-did-remount
|
||||||
:name "icons-page"
|
:name "icons-page"
|
||||||
:mixins [mx/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
|
|
|
@ -356,7 +356,7 @@
|
||||||
(di/initialize))
|
(di/initialize))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(defn- images-page-transfer-state
|
(defn- images-page-did-remount
|
||||||
[old-state state]
|
[old-state state]
|
||||||
(rs/emit! (dd/initialize :dashboard/images))
|
(rs/emit! (dd/initialize :dashboard/images))
|
||||||
state)
|
state)
|
||||||
|
@ -365,6 +365,6 @@
|
||||||
(mx/component
|
(mx/component
|
||||||
{:render images-page-render
|
{:render images-page-render
|
||||||
:will-mount images-page-will-mount
|
:will-mount images-page-will-mount
|
||||||
:transfer-state images-page-transfer-state
|
:did-remount images-page-did-remount
|
||||||
:name "images-page"
|
:name "images-page"
|
||||||
:mixins [mx/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
|
@ -234,7 +234,7 @@
|
||||||
(dp/initialize))
|
(dp/initialize))
|
||||||
own)
|
own)
|
||||||
|
|
||||||
(defn projects-page-transfer-state
|
(defn projects-page-did-remount
|
||||||
[old-state state]
|
[old-state state]
|
||||||
(rs/emit! (dd/initialize :dashboard/projects))
|
(rs/emit! (dd/initialize :dashboard/projects))
|
||||||
state)
|
state)
|
||||||
|
@ -243,7 +243,7 @@
|
||||||
(mx/component
|
(mx/component
|
||||||
{:render projects-page-render
|
{:render projects-page-render
|
||||||
:will-mount projects-page-will-mount
|
:will-mount projects-page-will-mount
|
||||||
:transfer-state projects-page-transfer-state
|
:did-remount projects-page-did-remount
|
||||||
:name "projects-page"
|
:name "projects-page"
|
||||||
:mixins [rum/static]}))
|
:mixins [rum/static]}))
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,6 @@
|
||||||
(events/unlistenByKey (::key own))
|
(events/unlistenByKey (::key own))
|
||||||
(dissoc own ::key))
|
(dissoc own ::key))
|
||||||
|
|
||||||
(defn- lightbox-transfer-state
|
|
||||||
[old-own own]
|
|
||||||
(assoc own ::key (::key old-own)))
|
|
||||||
|
|
||||||
(defn- lightbox-render
|
(defn- lightbox-render
|
||||||
[own]
|
[own]
|
||||||
(let [data (mx/react lightbox-l)
|
(let [data (mx/react lightbox-l)
|
||||||
|
@ -68,7 +64,6 @@
|
||||||
(mx/component
|
(mx/component
|
||||||
{:name "lightbox"
|
{:name "lightbox"
|
||||||
:render lightbox-render
|
:render lightbox-render
|
||||||
:transfer-state lightbox-transfer-state
|
|
||||||
:will-mount lightbox-will-mount
|
:will-mount lightbox-will-mount
|
||||||
:will-unmount lightbox-will-umount
|
:will-unmount lightbox-will-umount
|
||||||
:mixins [mx/reactive mx/static]}))
|
:mixins [mx/reactive mx/static]}))
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
(dissoc own ::sub1 ::sub2))
|
(dissoc own ::sub1 ::sub2))
|
||||||
|
|
||||||
(defn- workspace-transfer-state
|
(defn- workspace-did-remount
|
||||||
[old-state state]
|
[old-state state]
|
||||||
(let [[projectid pageid] (:rum/args state)
|
(let [[projectid pageid] (:rum/args state)
|
||||||
[oldprojectid oldpageid] (:rum/args old-state)]
|
[oldprojectid oldpageid] (:rum/args old-state)]
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
(def workspace
|
(def workspace
|
||||||
(mx/component
|
(mx/component
|
||||||
{:render workspace-render
|
{:render workspace-render
|
||||||
:transfer-state workspace-transfer-state
|
:did-remount workspace-did-remount
|
||||||
:will-mount workspace-will-mount
|
:will-mount workspace-will-mount
|
||||||
:will-unmount workspace-will-unmount
|
:will-unmount workspace-will-unmount
|
||||||
:did-mount workspace-did-mount
|
:did-mount workspace-did-mount
|
||||||
|
|
|
@ -19,23 +19,25 @@
|
||||||
|
|
||||||
;; --- Lenses
|
;; --- Lenses
|
||||||
|
|
||||||
(def ^:const workspace-l
|
(def workspace-l
|
||||||
(as-> (l/in [:workspace]) $
|
(-> (l/in [:workspace])
|
||||||
(l/derive $ st/state)))
|
(l/derive st/state)))
|
||||||
|
|
||||||
(def ^:const project-l
|
(def project-l
|
||||||
(letfn [(getter [state]
|
(letfn [(getter [state]
|
||||||
(let [project (get-in state [:workspace :project])]
|
(let [project (get-in state [:workspace :project])]
|
||||||
(get-in state [:projects-by-id project])))]
|
(get-in state [:projects-by-id project])))]
|
||||||
(as-> (l/lens getter) $
|
(-> (l/lens getter)
|
||||||
(l/derive $ st/state))))
|
(l/derive st/state))))
|
||||||
|
|
||||||
(def ^:const page-l
|
(def page-l
|
||||||
(letfn [(getter [state]
|
(letfn [(getter [state]
|
||||||
(let [page (get-in state [:workspace :page])]
|
(let [page (get-in state [:workspace :page])]
|
||||||
|
;; (println "page-l$getter" page)
|
||||||
|
|
||||||
(get-in state [:pages-by-id page])))]
|
(get-in state [:pages-by-id page])))]
|
||||||
(as-> (l/lens getter) $
|
(-> (l/lens getter)
|
||||||
(l/derive $ st/state))))
|
(l/derive st/state))))
|
||||||
|
|
||||||
(def ^:const selected-shapes-l
|
(def ^:const selected-shapes-l
|
||||||
(as-> (l/in [:selected]) $
|
(as-> (l/in [:selected]) $
|
||||||
|
|
|
@ -168,13 +168,6 @@
|
||||||
::key2 key2
|
::key2 key2
|
||||||
::key3 key3))))
|
::key3 key3))))
|
||||||
|
|
||||||
(defn- viewport-transfer-state
|
|
||||||
[old-own own]
|
|
||||||
(->> [::key1 ::key2 ::key3
|
|
||||||
::sub1 ::sub2]
|
|
||||||
(select-keys old-own)
|
|
||||||
(merge own)))
|
|
||||||
|
|
||||||
(defn- viewport-will-unmount
|
(defn- viewport-will-unmount
|
||||||
[own]
|
[own]
|
||||||
(events/unlistenByKey (::key1 own))
|
(events/unlistenByKey (::key1 own))
|
||||||
|
@ -190,5 +183,4 @@
|
||||||
:name "viewport"
|
:name "viewport"
|
||||||
:did-mount viewport-did-mount
|
:did-mount viewport-did-mount
|
||||||
:will-unmount viewport-will-unmount
|
:will-unmount viewport-will-unmount
|
||||||
:transfer-state viewport-transfer-state
|
|
||||||
:mixins [mx/reactive]}))
|
:mixins [mx/reactive]}))
|
||||||
|
|
|
@ -45,10 +45,6 @@
|
||||||
[own]
|
[own]
|
||||||
(assoc own ::sub (watch-draw-actions)))
|
(assoc own ::sub (watch-draw-actions)))
|
||||||
|
|
||||||
(defn- draw-area-transfer-state
|
|
||||||
[oldown own]
|
|
||||||
(assoc own ::sub (::sub oldown)))
|
|
||||||
|
|
||||||
(defn- draw-area-will-unmount
|
(defn- draw-area-will-unmount
|
||||||
[own]
|
[own]
|
||||||
(.close (::sub own))
|
(.close (::sub own))
|
||||||
|
@ -60,7 +56,6 @@
|
||||||
:name "draw-area"
|
:name "draw-area"
|
||||||
:will-mount draw-area-will-mount
|
:will-mount draw-area-will-mount
|
||||||
:will-unmount draw-area-will-unmount
|
:will-unmount draw-area-will-unmount
|
||||||
:transfer-state draw-area-transfer-state
|
|
||||||
:mixins [mx/static mx/reactive]}))
|
:mixins [mx/static mx/reactive]}))
|
||||||
|
|
||||||
;; --- Drawing Logic
|
;; --- Drawing Logic
|
||||||
|
|
|
@ -87,11 +87,6 @@
|
||||||
(subscription)
|
(subscription)
|
||||||
(dissoc own ::sub)))
|
(dissoc own ::sub)))
|
||||||
|
|
||||||
(defn- overlay-transfer-state
|
|
||||||
[old-own own]
|
|
||||||
(let [sub (::sub old-own)]
|
|
||||||
(assoc own ::sub sub)))
|
|
||||||
|
|
||||||
(declare overlay-line-render)
|
(declare overlay-line-render)
|
||||||
|
|
||||||
(defn- overlay-render
|
(defn- overlay-render
|
||||||
|
@ -115,7 +110,6 @@
|
||||||
{:render #(overlay-render % (:rum/local %))
|
{:render #(overlay-render % (:rum/local %))
|
||||||
:will-mount #(overlay-will-mount % (:rum/local %))
|
:will-mount #(overlay-will-mount % (:rum/local %))
|
||||||
:will-unmount overlay-will-unmount
|
:will-unmount overlay-will-unmount
|
||||||
:transfer-state overlay-transfer-state
|
|
||||||
:name "overlay"
|
:name "overlay"
|
||||||
:mixins [mx/static (mx/local) mx/reactive]}))
|
:mixins [mx/static (mx/local) mx/reactive]}))
|
||||||
|
|
||||||
|
|
|
@ -45,17 +45,12 @@
|
||||||
(.close (::sub own))
|
(.close (::sub own))
|
||||||
(dissoc own ::sub))
|
(dissoc own ::sub))
|
||||||
|
|
||||||
(defn- selrect-transfer-state
|
|
||||||
[oldown own]
|
|
||||||
(assoc own ::sub (::sub oldown)))
|
|
||||||
|
|
||||||
(def selrect
|
(def selrect
|
||||||
(mx/component
|
(mx/component
|
||||||
{:render selrect-render
|
{:render selrect-render
|
||||||
:name "selrect"
|
:name "selrect"
|
||||||
:will-mount selrect-will-mount
|
:will-mount selrect-will-mount
|
||||||
:will-unmount selrect-will-unmount
|
:will-unmount selrect-will-unmount
|
||||||
:transfer-state selrect-transfer-state
|
|
||||||
:mixins [mx/static mx/reactive]}))
|
:mixins [mx/static mx/reactive]}))
|
||||||
|
|
||||||
;; --- Implementation
|
;; --- Implementation
|
||||||
|
|
|
@ -105,11 +105,6 @@
|
||||||
(.close (::sub own))
|
(.close (::sub own))
|
||||||
(dissoc own ::sub))
|
(dissoc own ::sub))
|
||||||
|
|
||||||
(defn- transfer-state
|
|
||||||
[oldown own]
|
|
||||||
(assoc own ::sub (::sub oldown)))
|
|
||||||
|
|
||||||
(def shortcuts-mixin
|
(def shortcuts-mixin
|
||||||
{:will-mount will-mount
|
{:will-mount will-mount
|
||||||
:will-unmount will-unmount
|
:will-unmount will-unmount})
|
||||||
:transfer-state transfer-state})
|
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
(if (> total 1)
|
(if (> total 1)
|
||||||
[:a {:on-click on-delete} i/trash])]])))
|
[:a {:on-click on-delete} i/trash])]])))
|
||||||
|
|
||||||
(def ^:const page-item
|
(def page-item
|
||||||
(mx/component
|
(mx/component
|
||||||
{:render page-item-render
|
{:render page-item-render
|
||||||
:name "page-item"
|
:name "page-item"
|
||||||
|
|
Loading…
Add table
Reference in a new issue