mirror of
https://github.com/penpot/penpot.git
synced 2025-07-21 13:27:13 +02:00
💄 Add cosmetic changes (and comments) to toggle-file-thumbnail-selected function
This commit is contained in:
parent
541a372f01
commit
c2b6b40554
1 changed files with 19 additions and 11 deletions
|
@ -481,25 +481,33 @@
|
|||
(let [selected (wsh/lookup-selected state)]
|
||||
(rx/of (dch/update-shapes selected #(update % :blocked not)))))))
|
||||
|
||||
|
||||
;; FIXME: this need to be refactored
|
||||
|
||||
(defn toggle-file-thumbnail-selected
|
||||
[]
|
||||
(ptk/reify ::toggle-file-thumbnail-selected
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [selected (wsh/lookup-selected state)
|
||||
pages (-> state :workspace-data :pages-index vals)
|
||||
get-frames (fn [{:keys [objects id] :as page}]
|
||||
pages (-> state :workspace-data :pages-index vals)]
|
||||
|
||||
(rx/concat
|
||||
;; First: clear the `:use-for-thumbnail?` flag from all not
|
||||
;; selected frames.
|
||||
(rx/from
|
||||
(->> pages
|
||||
(mapcat
|
||||
(fn [{:keys [objects id] :as page}]
|
||||
(->> (ctst/get-frames objects)
|
||||
(sequence
|
||||
(comp (filter :use-for-thumbnail?)
|
||||
(map :id)
|
||||
(remove selected)
|
||||
(map (partial vector id))))))]
|
||||
|
||||
(rx/concat
|
||||
(rx/from
|
||||
(->> (mapcat get-frames pages)
|
||||
(map (partial vector id)))))))
|
||||
(d/group-by first second)
|
||||
(map (fn [[page-id frame-ids]]
|
||||
(dch/update-shapes frame-ids #(dissoc % :use-for-thumbnail?) {:page-id page-id})))))
|
||||
|
||||
;; And finally: toggle the flag value on all the selected shapes
|
||||
(rx/of (dch/update-shapes selected #(update % :use-for-thumbnail? not))))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue