From 9c9bc8803d0c21a8f52262af08d093bdfec61887 Mon Sep 17 00:00:00 2001 From: Aitor Date: Thu, 28 Sep 2023 16:42:09 +0200 Subject: [PATCH] :bug: Fix render-frame when shape is nil --- frontend/src/app/main/render.cljs | 69 ++++++++++++++++--------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 5de3d999f1..bf1f439da8 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -538,42 +538,45 @@ (defn render-frame [objects shape object-id] - (let [shape-id (dm/get-prop shape :id) - fonts (ff/shape->fonts shape objects) + (if (some? shape) + (let [shape-id (dm/get-prop shape :id) + fonts (ff/shape->fonts shape objects) - bounds (if (:show-content shape) - (let [ids (cph/get-children-ids objects shape-id) - children (sequence (keep (d/getf objects)) ids)] - (gsh/shapes->rect (cons shape children))) - (-> shape :points grc/points->rect)) + bounds (if (:show-content shape) + (let [ids (cph/get-children-ids objects shape-id) + children (sequence (keep (d/getf objects)) ids)] + (gsh/shapes->rect (cons shape children))) + (-> shape :points grc/points->rect)) - x (dm/get-prop bounds :x) - y (dm/get-prop bounds :y) - width (dm/get-prop bounds :width) - height (dm/get-prop bounds :height) + x (dm/get-prop bounds :x) + y (dm/get-prop bounds :y) + width (dm/get-prop bounds :width) + height (dm/get-prop bounds :height) - viewbox (str/ffmt "% % % %" x y width height) + viewbox (str/ffmt "% % % %" x y width height) - [fixed-width - fixed-height] (th/get-proportional-size width height) + [fixed-width + fixed-height] (th/get-proportional-size width height) - data (rds/renderToStaticMarkup - (mf/element frame-imposter - #js {:objects objects - :frame shape - :vbox viewbox - :width width - :height height}))] + data (rds/renderToStaticMarkup + (mf/element frame-imposter + #js {:objects objects + :frame shape + :vbox viewbox + :width width + :height height}))] - (->> (fonts/render-font-styles-cached fonts) - (rx/catch (fn [cause] - (l/err :hint "unexpected error on rendering imposter" - :cause cause) - (rx/empty))) - (rx/map (fn [styles] - {:id object-id - :data data - :viewbox viewbox - :width fixed-width - :height fixed-height - :styles styles}))))) + (->> (fonts/render-font-styles-cached fonts) + (rx/catch (fn [cause] + (l/err :hint "unexpected error on rendering imposter" + :cause cause) + (rx/empty))) + (rx/map (fn [styles] + {:id object-id + :data data + :viewbox viewbox + :width fixed-width + :height fixed-height + :styles styles})))) + (do (l/warn :msg "imposter shape is nil") + (rx/empty))))