about summary refs log tree commit diff
path: root/src/view/com/modals/EditImage.tsx
diff options
context:
space:
mode:
authorOllie H <renahlee@outlook.com>2023-05-30 17:23:55 -0700
committerGitHub <noreply@github.com>2023-05-30 19:23:55 -0500
commit072682dd9f8843787229a98fbeea24161bc0c9b4 (patch)
tree931c55dd298e36e363bb0366f41d671043f091ba /src/view/com/modals/EditImage.tsx
parentdeebe18aaa883d7fcedabd594dda057f991c3026 (diff)
downloadvoidsky-072682dd9f8843787229a98fbeea24161bc0c9b4.tar.zst
Rework scaled dimensions and compression (#737)
* Rework scaled dimensions and compression

* Unbreak image / banner uploads

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/view/com/modals/EditImage.tsx')
-rw-r--r--src/view/com/modals/EditImage.tsx13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/view/com/modals/EditImage.tsx b/src/view/com/modals/EditImage.tsx
index eab472a78..09ae01943 100644
--- a/src/view/com/modals/EditImage.tsx
+++ b/src/view/com/modals/EditImage.tsx
@@ -118,9 +118,9 @@ export const Component = observer(function ({image, gallery}: Props) {
   )
 
   useEffect(() => {
-    image.prev = image.compressed
+    image.prev = image.cropped
     image.prevAttributes = image.attributes
-    image.resetCompressed()
+    image.resetCropped()
   }, [image])
 
   const onCloseModal = useCallback(() => {
@@ -152,7 +152,7 @@ export const Component = observer(function ({image, gallery}: Props) {
         : {}),
     })
 
-    image.prev = image.compressed
+    image.prev = image.cropped
     image.prevAttributes = image.attributes
     onCloseModal()
   }, [altText, image, position, scale, onCloseModal])
@@ -168,8 +168,7 @@ export const Component = observer(function ({image, gallery}: Props) {
     }
   }, [])
 
-  // Prevents preliminary flash when transformations are being applied
-  if (image.compressed === undefined) {
+  if (image.cropped === undefined) {
     return null
   }
 
@@ -177,7 +176,7 @@ export const Component = observer(function ({image, gallery}: Props) {
     windowDimensions.width > 500 ? 410 : windowDimensions.width - 80
   const sideLength = isDesktopWeb ? 300 : computedWidth
 
-  const dimensions = image.getDisplayDimensions(aspectRatio, sideLength)
+  const dimensions = image.getResizedDimensions(aspectRatio, sideLength)
   const imgContainerStyles = {width: sideLength, height: sideLength}
 
   const imgControlStyles = {
@@ -196,7 +195,7 @@ export const Component = observer(function ({image, gallery}: Props) {
             <ImageEditor
               ref={editorRef}
               style={styles.imgEditor}
-              image={image.compressed.path}
+              image={image.cropped.path}
               scale={scale}
               border={0}
               position={position}