diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index e70e5d08d..6cc5aa6c4 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -512,10 +512,11 @@ id-duplicated (first new-selected)] - ;; Warning: This order is important for the focus mode. - (rx/merge + (rx/concat (->> (rx/from dup-frames) (rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id)))) + + ;; Warning: This order is important for the focus mode. (rx/of (dch/commit-changes changes) (select-shapes new-selected) (memorize-duplicated id-original id-duplicated)))))))))) diff --git a/frontend/src/app/main/data/workspace/thumbnails.cljs b/frontend/src/app/main/data/workspace/thumbnails.cljs index d12ab34a0..a0ed270e4 100644 --- a/frontend/src/app/main/data/workspace/thumbnails.cljs +++ b/frontend/src/app/main/data/workspace/thumbnails.cljs @@ -7,6 +7,7 @@ (ns app.main.data.workspace.thumbnails (:require [app.common.data :as d] + [app.common.pages.helpers :as cph] [app.common.uuid :as uuid] [app.main.data.workspace.changes :as dch] [app.main.refs :as refs] @@ -49,17 +50,15 @@ ;; the 2 second debounce is finished (rx/merge (->> stream - (rx/take-until stopper) (rx/filter (ptk/type? ::update-thumbnail)) - (rx/filter #(= id (:id (deref %)))) + (rx/map deref) + (rx/filter #(= id (:id %))) (rx/debounce 2000) - (rx/first) - (rx/flat-map - (fn [event] - (let [data (:data @event)] - (rp/mutation! :upsert-file-object-thumbnail (assoc params :data data))))) - - (rx/map #(fn [state] (d/dissoc-in state [::update-thumbnail-lock id])))) + (rx/take 1) + (rx/map :data) + (rx/flat-map #(rp/mutation! :upsert-file-object-thumbnail (assoc params :data %))) + (rx/map #(fn [state] (d/dissoc-in state [::update-thumbnail-lock id]))) + (rx/take-until stopper)) (->> (rx/of (update-thumbnail id data)) (rx/observe-on :async))))))))) @@ -98,9 +97,7 @@ (fn [id] (let [shape (or (get new-objects id) (get old-objects id))] - - (or (and (= :frame (:type shape)) id) - (:frame-id shape)))) + (or (and (cph/frame-shape? shape) id) (:frame-id shape)))) ;; Extracts the frames and then removes nils and the root frame xform (comp (mapcat extract-ids) @@ -151,17 +148,17 @@ ;; Async so we wait for additional side-effects of commit-changes (rx/observe-on :async) - (rx/filter (comp not thumbnail-change?)) + (rx/filter (complement thumbnail-change?)) (rx/with-latest-from objects-stream) (rx/map extract-frame-changes) (rx/share))] (->> frame-changes - (rx/take-until stopper) (rx/flat-map (fn [ids] (->> (rx/from ids) - (rx/map #(ptk/data-event ::force-render %)))))))))) + (rx/map #(ptk/data-event ::force-render %))))) + (rx/take-until stopper)))))) (defn duplicate-thumbnail [old-id new-id] diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index 2d5514c2e..961f6af36 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -396,7 +396,7 @@ st/state)) (def thumbnail-data - (l/derived #(get-in % [:workspace-file :thumbnails] {}) st/state)) + (l/derived #(dm/get-in % [:workspace-file :thumbnails] {}) st/state)) (defn thumbnail-frame-data [frame-id] diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 54074465d..b170a2c08 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -402,7 +402,7 @@ :style {:-webkit-print-color-adjust :exact} :fill "none"} - (let [fonts (ff/frame->fonts obj-id objects)] + (let [fonts (ff/frame->fonts object-id objects)] [:& ff/fontfaces-style {:fonts fonts}]) (case (:type object) diff --git a/frontend/src/app/main/ui/shapes/mask.cljs b/frontend/src/app/main/ui/shapes/mask.cljs index f50145291..1d7bfdc7d 100644 --- a/frontend/src/app/main/ui/shapes/mask.cljs +++ b/frontend/src/app/main/ui/shapes/mask.cljs @@ -8,7 +8,6 @@ (:require [app.common.data :as d] [app.common.geom.shapes :as gsh] - [app.common.geom.shapes.text :as gst] [app.main.ui.context :as muc] [cuerdas.core :as str] [rumext.alpha :as mf])) diff --git a/frontend/src/app/main/ui/shapes/svg_raw.cljs b/frontend/src/app/main/ui/shapes/svg_raw.cljs index b2b27b483..ca950985e 100644 --- a/frontend/src/app/main/ui/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/shapes/svg_raw.cljs @@ -34,9 +34,9 @@ (obj/set! "style" style)))) (defn translate-shape [attrs shape] - (let [transform (str (usvg/svg-transform-matrix shape) - " " - (:transform attrs ""))] + (let [transform (dm/str (usvg/svg-transform-matrix shape) + " " + (:transform attrs ""))] (cond-> attrs (and (:svg-viewbox shape) (graphic-element? (-> shape :content :tag))) (assoc :transform transform)))) @@ -60,7 +60,7 @@ (obj/set! "preserveAspectRatio" "none"))] [:& (mf/provider svg-ids-ctx) {:value ids-mapping} - [:g.svg-raw {:transform (str (gsh/transform-matrix shape))} + [:g.svg-raw {:transform (dm/str (gsh/transform-matrix shape))} [:> "svg" attrs children]]])) (mf/defc svg-element diff --git a/frontend/src/app/main/ui/shapes/text/fontfaces.cljs b/frontend/src/app/main/ui/shapes/text/fontfaces.cljs index 1b70034c0..f2a903948 100644 --- a/frontend/src/app/main/ui/shapes/text/fontfaces.cljs +++ b/frontend/src/app/main/ui/shapes/text/fontfaces.cljs @@ -76,15 +76,15 @@ (defn frame->fonts [frame objects] (->> (cph/get-children objects (:id frame)) - (filterv cph/text-shape?) - (mapv (comp fonts/get-content-fonts :content)) + (filter cph/text-shape?) + (map (comp fonts/get-content-fonts :content)) (reduce set/union #{}))) (defn shapes->fonts [shapes] (->> shapes - (filterv cph/text-shape?) - (mapv (comp fonts/get-content-fonts :content)) + (filter cph/text-shape?) + (map (comp fonts/get-content-fonts :content)) (reduce set/union #{}))) (mf/defc fontfaces-style diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index a81c8b5d1..b2b9a8c97 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -7,6 +7,7 @@ (ns app.main.ui.workspace.shapes.frame (:require [app.common.data :as d] + [app.common.data.macros :as dm] [app.main.data.workspace.thumbnails :as dwt] [app.main.refs :as refs] [app.main.ui.hooks :as hooks] @@ -35,9 +36,9 @@ childs (mf/deref childs-ref)] [:& (mf/provider embed/context) {:value true} - [:> shape-container #js {:shape shape :ref ref} + [:& shape-container {:shape shape :ref ref} [:& ff/fontfaces-style {:fonts fonts}] - [:> frame-shape {:shape shape :childs childs} ]]])))) + [:& frame-shape {:shape shape :childs childs} ]]])))) (defn check-props [new-props old-props] @@ -80,7 +81,7 @@ modifiers-ref (mf/use-memo (mf/deps frame-id) #(refs/workspace-modifiers-by-frame-id frame-id)) modifiers (mf/deref modifiers-ref) - disable-thumbnail? (d/not-empty? (get-in modifiers [(:id shape) :modifiers])) + disable-thumbnail? (d/not-empty? (dm/get-in modifiers [(:id shape) :modifiers])) [on-load-frame-dom thumb-renderer] (ftr/use-render-thumbnail shape node-ref rendered? thumbnail? disable-thumbnail?) diff --git a/frontend/src/debug.cljs b/frontend/src/debug.cljs index 3e3249359..1cbd600bf 100644 --- a/frontend/src/debug.cljs +++ b/frontend/src/debug.cljs @@ -68,7 +68,7 @@ #{:app.main.data.workspace.notifications/handle-pointer-update :app.main.data.workspace.selection/change-hover-state}) -(defonce ^:dynamic *debug* (atom #{#_:events :thumbnails})) +(defonce ^:dynamic *debug* (atom #{#_:events})) (defn debug-all! [] (reset! *debug* debug-options)) (defn debug-none! [] (reset! *debug* #{}))