💄 Change some code styles

This commit is contained in:
Andrés Moya 2022-03-10 15:21:14 +01:00
parent e609670a41
commit 7b81bb3fc2
5 changed files with 57 additions and 47 deletions

View file

@ -288,7 +288,9 @@
cp/default-shape-attrs)
selected-non-frames
(into #{} (filter #(not= (:type (get objects %)) :frame) selected))
(into #{} (comp (map (d/getf objects))
(remove cph/frame-shape?))
selected)
[frame-id parent-id index]
(get-shape-layer-position objects selected-non-frames attrs)]
@ -364,7 +366,6 @@
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
page (wsh/lookup-page state page-id)
flows (-> page :options :flows)
ids (cph/clean-loops objects ids)
@ -397,7 +398,7 @@
;; If any of the deleted is a frame that starts a flow,
;; this must be deleted, too.
(contains? ids (:starting-frame flow)))
flows)
(-> page :options :flows))
all-parents
(reduce (fn [res id]
@ -448,10 +449,10 @@
interactions))))))
(cond->
(seq starting-flows)
(pcb/set-page-option :flows
(reduce #(csp/remove-flow %1 (:id %2))
flows
starting-flows))))]
(pcb/update-page-option :flows (fn [flows]
(reduce #(csp/remove-flow %1 (:id %2))
flows
starting-flows)))))]
(rx/of (dch/commit-changes changes))))))

View file

@ -28,14 +28,11 @@
(ptk/reify ::update-guides
ptk/WatchEvent
(watch [it state _]
(let [page (wsh/lookup-page state)
guides (get-in page [:options :guides] {})
new-guides (assoc guides (:id guide) guide)
(let [page (wsh/lookup-page state)
changes
(-> (pcb/empty-changes it)
(pcb/with-page page)
(pcb/set-page-option :guides new-guides))]
(pcb/update-page-option :guides assoc (:id guide) guide))]
(rx/of (dwc/commit-changes changes))))))
(defn remove-guide [guide]
@ -49,14 +46,11 @@
ptk/WatchEvent
(watch [it state _]
(let [page (wsh/lookup-page state)
guides (get-in page [:options :guides] {})
new-guides (dissoc guides (:id guide))
(let [page (wsh/lookup-page state)
changes
(-> (pcb/empty-changes it)
(pcb/with-page page)
(pcb/set-page-option :guides new-guides))]
(pcb/update-page-option :guides dissoc (:id guide)))]
(rx/of (dwc/commit-changes changes))))))
(defn remove-guides

View file

@ -29,8 +29,8 @@
ptk/WatchEvent
(watch [it state _]
(let [page (wsh/lookup-page state)
flows (get-in page [:options :flows] [])
flows (get-in page [:options :flows] [])
unames (into #{} (map :name flows))
name (dwc/generate-unique-name unames "Flow-1")
@ -41,8 +41,7 @@
(rx/of (dch/commit-changes
(-> (pcb/empty-changes it)
(pcb/with-page page)
(pcb/set-page-option :flows
(csp/add-flow flows new-flow)))))))))
(pcb/update-page-option :flows csp/add-flow new-flow))))))))
(defn add-flow-selected-frame
[]
@ -58,13 +57,11 @@
(ptk/reify ::remove-flow
ptk/WatchEvent
(watch [it state _]
(let [page (wsh/lookup-page state)
flows (get-in page [:options :flows] [])]
(let [page (wsh/lookup-page state)]
(rx/of (dch/commit-changes
(-> (pcb/empty-changes it)
(pcb/with-page page)
(pcb/set-page-option :flows
(csp/remove-flow flows flow-id)))))))))
(pcb/update-page-option :flows csp/remove-flow flow-id))))))))
(defn rename-flow
[flow-id name]
@ -73,14 +70,12 @@
(ptk/reify ::rename-flow
ptk/WatchEvent
(watch [it state _]
(let [page (wsh/lookup-page state)
flows (get-in page [:options :flows] [])]
(let [page (wsh/lookup-page state) ]
(rx/of (dch/commit-changes
(-> (pcb/empty-changes it)
(pcb/with-page page)
(pcb/set-page-option :flows
(csp/update-flow flows flow-id
#(csp/rename-flow % name))))))))))
(pcb/update-page-option :flows csp/update-flow flow-id
#(csp/rename-flow % name)))))))))
(defn start-rename-flow
[id]

View file

@ -376,17 +376,18 @@
(filter #(= (:type %) :frame))
(filter #(some? (ctp/get-frame-flow flows (:id %)))))]
(if-not (empty? frames-with-flow)
(let [new-flows (reduce
(fn [flows frame]
(let [name (dwc/generate-unique-name @unames "Flow-1")
_ (vswap! unames conj name)
new-flow {:id (uuid/next)
:name name
:starting-frame (get ids-map (:id frame))}]
(ctp/add-flow flows new-flow)))
flows
frames-with-flow)]
(pcb/set-page-option changes :flows new-flows))
(let [update-flows (fn [flows]
(reduce
(fn [flows frame]
(let [name (dwc/generate-unique-name @unames "Flow-1")
_ (vswap! unames conj name)
new-flow {:id (uuid/next)
:name name
:starting-frame (get ids-map (:id frame))}]
(ctp/add-flow flows new-flow)))
flows
frames-with-flow))]
(pcb/update-page-option changes :flows update-flows))
changes)))
(defn duplicate-changes-update-indices