From 0f2b2d45902790167a984a16e6b6958f2492be63 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 25 May 2022 11:22:59 +0200 Subject: [PATCH 1/2] :bug: Fix problem with hanging file --- .../workspace/shapes/text/viewport_texts.cljs | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts.cljs b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts.cljs index 5e7823b90..77f9eb29f 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts.cljs @@ -62,20 +62,22 @@ (assoc :content (d/txt-merge content editor-content))))) (defn- update-text-shape - [{:keys [grow-type id]} node] + [{:keys [grow-type id migrate]} node] ;; Check if we need to update the size because it's auto-width or auto-height - (when (contains? #{:auto-height :auto-width} grow-type) - (let [{:keys [width height]} - (-> (dom/query node ".paragraph-set") - (dom/get-client-size)) - width (mth/ceil width) - height (mth/ceil height)] - (when (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height))) - (st/emit! (dwt/resize-text id width height))))) - ;; Update the position-data of every text fragment (p/let [position-data (utp/calc-position-data node)] - (st/emit! (dwt/update-position-data id position-data))) + (st/emit! (dwt/update-position-data id position-data)) + + (when (contains? #{:auto-height :auto-width} grow-type) + (let [{:keys [width height]} + (-> (dom/query node ".paragraph-set") + (dom/get-client-size)) + width (mth/ceil width) + height (mth/ceil height)] + (when (and (not (mth/almost-zero? width)) + (not (mth/almost-zero? height)) + (not migrate)) + (st/emit! (dwt/resize-text id width height)))))) (st/emit! (dwt/clean-text-modifier id))) @@ -229,7 +231,14 @@ (mf/deps text-shapes modifiers) #(d/update-vals text-shapes (partial process-shape modifiers))) - editing-shape (get text-shapes edition)] + editing-shape (get text-shapes edition) + + ;; This memo is necesary so the viewport-text-wrapper memoize its props correctly + text-shapes-wrapper + (mf/use-memo + (mf/deps text-shapes edition) + (fn [] + (dissoc text-shapes edition)))] ;; We only need the effect to run on "mount" because the next fonts will be changed when the texts are ;; edited @@ -243,5 +252,5 @@ (when editing-shape [:& viewport-text-editing {:shape editing-shape}]) - [:& viewport-texts-wrapper {:text-shapes (dissoc text-shapes edition) + [:& viewport-texts-wrapper {:text-shapes text-shapes-wrapper :modifiers modifiers}]])) From 18849307e97aa308ccaeb609aab44407c3eb4873 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 25 May 2022 11:29:49 +0200 Subject: [PATCH 2/2] :bug: Fix linting issue --- backend/src/app/http/debug.clj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 0c534a192..35e9ed27f 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -102,8 +102,7 @@ (let [fname (str "imported-file-" (dt/now)) file-id (try (uuid/uuid (-> params :file :filename)) - (catch Exception err - (uuid/next))) + (catch Exception _ (uuid/next))) file (db/exec-one! pool (sql/select :file {:id file-id}))] (if file (db/update! pool :file