From 36506ec3605c770df0ea81a4164eade0045fff83 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 5 Sep 2023 12:01:40 +0200 Subject: [PATCH] :bug: Replace `:use-for-thumbnail?` with `:use-for-thumbnail` --- backend/src/app/rpc/commands/files_thumbnails.clj | 4 ++-- common/src/app/common/files/defaults.cljc | 2 +- common/src/app/common/files/migrations.cljc | 15 +++++++++++++++ common/src/app/common/types/file.cljc | 4 ++-- frontend/src/app/main/data/workspace.cljs | 2 +- .../src/app/main/data/workspace/selection.cljs | 4 ++-- frontend/src/app/main/data/workspace/shapes.cljs | 8 ++++---- .../src/app/main/ui/workspace/context_menu.cljs | 2 +- .../app/main/ui/workspace/viewport/widgets.cljs | 6 +++--- 9 files changed, 31 insertions(+), 16 deletions(-) diff --git a/backend/src/app/rpc/commands/files_thumbnails.clj b/backend/src/app/rpc/commands/files_thumbnails.clj index 1db0c4ccd..28105314e 100644 --- a/backend/src/app/rpc/commands/files_thumbnails.clj +++ b/backend/src/app/rpc/commands/files_thumbnails.clj @@ -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))))) diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index 3cfaccf20..7f0ff7c13 100644 --- a/common/src/app/common/files/defaults.cljc +++ b/common/src/app/common/files/defaults.cljc @@ -6,4 +6,4 @@ (ns app.common.files.defaults) -(def version 30) +(def version 31) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index df4144c87..14a1a5a97 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -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)))) diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index 85660994d..de81cfd82 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -974,7 +974,7 @@ (report-error :missing-component-root (str/format "Referenced shape %s not found in near component" (:shape-ref shape)) shape file page)))) - + (defn validate-component-not-ref "Validate that this shape does not reference other one." [shape file page report-error] @@ -1065,7 +1065,7 @@ (defn validate-shape "Validate referential integrity and semantic coherence of a shape and all its children. - + The context is the situation of the parent in respect to components: :not-component :main-top diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index e4e37c3f7..173226d09 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -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))) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 35d7eb2b8..86bd27c8d 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -449,8 +449,8 @@ :frame-id frame-id) (dissoc :shapes - :main-instance? - :use-for-thumbnail?) + :main-instance + :use-for-thumbnail) (cond-> (or frame? group? bool?) diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 9631d626e..7c59da35b 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -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)))))))) diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 80c625f59..af6e2768f 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -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") diff --git a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs index 53f56fedc..bb6fb4a7c 100644 --- a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs @@ -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?