From 532f0fa22281fef1e35e3d0a6064ee57e4673253 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 28 Feb 2025 14:52:39 -0500
Subject: added drop target for regenerating images

---
 src/client/views/smartdraw/DrawingFillHandler.tsx | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

(limited to 'src/client/views/smartdraw/DrawingFillHandler.tsx')

diff --git a/src/client/views/smartdraw/DrawingFillHandler.tsx b/src/client/views/smartdraw/DrawingFillHandler.tsx
index 7447f8afb..0a30b14b8 100644
--- a/src/client/views/smartdraw/DrawingFillHandler.tsx
+++ b/src/client/views/smartdraw/DrawingFillHandler.tsx
@@ -28,19 +28,15 @@ export class DrawingFillHandler {
             const hrefParts = ImageCast(styleImg).url.href.split('.');
             return `${hrefParts.slice(0, -1).join('.')}_o.${hrefParts.lastElement()}`;
         });
-        DocumentView.GetDocImage(drawing)?.then(imageField => {
+        return DocumentView.GetDocImage(drawing)?.then(imageField => {
             if (imageField) {
                 const aspectRatio = (drawing.width as number) / (drawing.height as number);
-                let dims: { width: number; height: number };
-                if (aspectRatio > AspectRatioLimits[FireflyImageDimensions.Widescreen]) {
-                    dims = FireflyDimensionsMap[FireflyImageDimensions.Widescreen];
-                } else if (aspectRatio > AspectRatioLimits[FireflyImageDimensions.Landscape]) {
-                    dims = FireflyDimensionsMap[FireflyImageDimensions.Landscape];
-                } else if (aspectRatio < AspectRatioLimits[FireflyImageDimensions.Portrait]) {
-                    dims = FireflyDimensionsMap[FireflyImageDimensions.Portrait];
-                } else {
-                    dims = FireflyDimensionsMap[FireflyImageDimensions.Square];
-                }
+                const dims = (() => {
+                    if (aspectRatio > AspectRatioLimits[FireflyImageDimensions.Widescreen]) return FireflyDimensionsMap[FireflyImageDimensions.Widescreen];
+                    if (aspectRatio > AspectRatioLimits[FireflyImageDimensions.Landscape]) return FireflyDimensionsMap[FireflyImageDimensions.Landscape];
+                    if (aspectRatio < AspectRatioLimits[FireflyImageDimensions.Portrait]) return FireflyDimensionsMap[FireflyImageDimensions.Portrait];
+                    return FireflyDimensionsMap[FireflyImageDimensions.Square];
+                })();
                 const { href } = ImageCast(imageField).url;
                 const hrefParts = href.split('.');
                 const structureUrl = `${hrefParts.slice(0, -1).join('.')}_o.${hrefParts.lastElement()}`;
@@ -62,7 +58,10 @@ export class DrawingFillHandler {
                                             _width: 500,
                                             data_nativeWidth: info.nativeWidth,
                                             data_nativeHeight: info.nativeHeight,
-                                        })
+                                        }),
+                                        undefined,
+                                        undefined,
+                                        true
                                     )
                                 );
                                 if (!DocumentView.getFirstDocumentView(genratedDocs)) DocumentViewInternal.addDocTabFunc(genratedDocs, OpenWhere.addRight);
-- 
cgit v1.2.3-70-g09d2

