0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Merge pull request #3599 from penpot/niwinz-develop-experiments-3

🐛 Replace `:use-for-thumbnail?` with `:use-for-thumbnail`
This commit is contained in:
Alejandro 2023-09-14 06:39:06 +02:00 committed by GitHub
commit a4754a2106
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 14 deletions

View file

@ -144,8 +144,8 @@
(run! pmap/load!))
;; Then proceed to find the frame set for thumbnail
(d/seek :use-for-thumbnail?
(d/seek #(or (:use-for-thumbnail %)
(:use-for-thumbnail? %)) ; NOTE: backward comp (remove on v1.21)
(for [page (-> data :pages-index vals)
frame (-> page :objects ctt/get-frames)]
(assoc frame :page-id (:id page)))))

View file

@ -6,4 +6,4 @@
(ns app.common.files.defaults)
(def version 30)
(def version 31)

View file

@ -576,3 +576,18 @@
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))
(defmethod migrate 31
[data]
(letfn [(update-object [object]
(cond-> object
(contains? object :use-for-thumbnail?)
(-> (assoc :use-for-thumbnail (:use-for-thumbnail? object))
(dissoc :use-for-thumbnail?))))
(update-container [container]
(d/update-when container :objects update-vals update-object))]
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))

View file

@ -462,7 +462,7 @@
fdata (:workspace-data state)
components-v2 (dm/get-in fdata [:options :components-v2])
objects (->> (:objects page)
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail?))))
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail))))
main-instances-ids (set (keep #(when (ctk/main-instance? (val %)) (key %)) objects))
ids-to-remove (set (apply concat (map #(cph/get-children-ids objects %) main-instances-ids)))

View file

@ -450,8 +450,8 @@
:frame-id frame-id)
(dissoc :shapes
:main-instance?
:use-for-thumbnail?)
:main-instance
:use-for-thumbnail)
(cond->
(or frame? group? bool?)

View file

@ -504,7 +504,7 @@
pages (-> state :workspace-data :pages-index vals)]
(rx/concat
;; First: clear the `:use-for-thumbnail?` flag from all not
;; First: clear the `:use-for-thumbnail` flag from all not
;; selected frames.
(rx/from
(->> pages
@ -512,13 +512,13 @@
(fn [{:keys [objects id] :as page}]
(->> (ctst/get-frames objects)
(sequence
(comp (filter :use-for-thumbnail?)
(comp (filter :use-for-thumbnail)
(map :id)
(remove selected)
(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})))))
(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))))))))
(rx/of (dch/update-shapes selected #(update % :use-for-thumbnail not))))))))

View file

@ -237,7 +237,7 @@
do-toggle-thumbnail #(st/emit! (dw/toggle-file-thumbnail-selected))]
(when (and single? has-frame?)
[:*
(if (every? :use-for-thumbnail? shapes)
(if (every? :use-for-thumbnail shapes)
[:& menu-entry {:title (tr "workspace.shape.menu.thumbnail-remove")
:on-click do-toggle-thumbnail}]
[:& menu-entry {:title (tr "workspace.shape.menu.thumbnail-set")

View file

@ -170,7 +170,7 @@
(on-frame-leave (:id frame))))
main-instance? (ctk/main-instance? frame)
text-pos-x (if (or (:use-for-thumbnail? frame) grid-edition? main-instance?) 15 0)]
text-pos-x (if (or (:use-for-thumbnail frame) grid-edition? main-instance?) 15 0)]
(when (not (:hidden frame))
[:g.frame-title {:id (dm/str "frame-title-" (:id frame))
@ -178,7 +178,7 @@
:transform (vwu/title-transform frame zoom grid-edition?)
:pointer-events (when (:blocked frame) "none")}
(cond
(or (:use-for-thumbnail? frame) grid-edition? main-instance?)
(or (:use-for-thumbnail frame) grid-edition? main-instance?)
[:svg {:x 0
:y -9
:width 12
@ -187,7 +187,7 @@
:style {:fill color}
:visibility (if show-artboard-names? "visible" "hidden")}
(cond
(:use-for-thumbnail? frame)
(:use-for-thumbnail frame)
[:use {:href "#icon-set-thumbnail"}]
grid-edition?