diff --git a/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx b/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx index 2aafee3de..570919a12 100644 --- a/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx +++ b/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx @@ -50,9 +50,6 @@ export const ImageEditorOverlayContext = createContext( const ImageEditorOverlay = (props: IProps) => { // const [originalWidth, originalHeight] = [props.file?.w, props.file?.h]; - const [originalWidth, setOriginalWidth] = useState(0); - const [originalHeight, setOriginalHeight] = useState(0); - const canvasRef = useRef(null); const originalSizeCanvasRef = useRef(null); const parentRef = useRef(null); @@ -76,8 +73,6 @@ const ImageEditorOverlay = (props: IProps) => { const [transformationPerformed, setTransformationPerformed] = useState(false); - const [canvasLoading, setCanvasLoading] = useState(false); - useEffect(() => { if (!canvasRef.current || !originalSizeCanvasRef.current) { return; @@ -149,8 +144,6 @@ const ImageEditorOverlay = (props: IProps) => { // setNonFilteredFileURL(img.src); img.onload = () => { - setOriginalWidth(img.width); - setOriginalHeight(img.height); const scale = Math.min( parentRef.current?.clientWidth / img.width, parentRef.current?.clientHeight / img.height @@ -190,20 +183,7 @@ const ImageEditorOverlay = (props: IProps) => { const context = canvas.getContext('2d'); if (!context) return; - - image.onload = () => { - context.clearRect(0, 0, canvas.width, canvas.height); - context.save(); - console.log(originalWidth, originalHeight); - canvas.width = originalWidth; - canvas.height = originalHeight; - - context.drawImage(image, 0, 0, originalWidth, originalHeight); - context.restore(); - console.log('canvas redrawn'); - console.log('toblobbing now'); - canvas.toBlob(callback, mimeType); - }; + canvas.toBlob(callback, mimeType); }; return ( @@ -233,9 +213,7 @@ const ImageEditorOverlay = (props: IProps) => { display="flex" alignItems="center" justifyContent="center"> - {(fileURL === null || canvasLoading) && ( - - )} + {fileURL === null && } { // maxWidth: '100%', // maxHeight: '1000px', display: - fileURL === null || canvasLoading - ? 'none' - : 'block', + fileURL === null ? 'none' : 'block', position: 'absolute', // transform: `translate(${cropOffsetX}px, ${cropOffsetY}px)`, }} @@ -341,11 +317,9 @@ const ImageEditorOverlay = (props: IProps) => { startIcon={} onClick={() => { if (!canvasRef.current) return; - setCanvasLoading(true); exportCanvasToBlob((blob) => { if (!blob) { - setCanvasLoading(false); return console.error('no blob'); } // create a link @@ -358,7 +332,6 @@ const ImageEditorOverlay = (props: IProps) => { a.click(); document.body.removeChild(a); URL.revokeObjectURL(a.href); - setCanvasLoading(false); }); }} label={'Download Edited'}