Skip to content

Commit

Permalink
Merge pull request #431 from picsoritdidnthappen/remove-compresion
Browse files Browse the repository at this point in the history
feat: Remove `browser-image-compression`
  • Loading branch information
picsoritdidnthappen authored Dec 20, 2024
2 parents 6bca9e0 + c6eef2e commit f589717
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 37 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@trpc/react-query": "11.0.0-rc.592",
"@trpc/server": "11.0.0-rc.592",
"axios": "^1.6.8",
"browser-image-compression": "^2.0.2",
"clsx": "^2.0.0",
"framer-motion": "^11.0.12",
"mobx": "^6.12.3",
Expand Down
21 changes: 3 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 1 addition & 18 deletions src/components/global/FormClaim.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import imageCompression from 'browser-image-compression';
import { useCallback, useEffect, useState } from 'react';
import { useDropzone } from 'react-dropzone';
import { toast } from 'react-toastify';
Expand Down Expand Up @@ -56,21 +55,6 @@ export default function FormClaim({

const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });

const compressImage = async (image: File): Promise<File> => {
const options = {
maxSizeMB: 10,
maxWidthOrHeight: 1920,
useWebWorker: true,
};
try {
const compressedFile = await imageCompression(image, options);
return compressedFile;
} catch (error) {
toast.error('Error compressing image');
throw error;
}
};

const retryUpload = async (file: File): Promise<string> => {
const MAX_RETRIES = 6;
const RETRY_DELAY = 3000;
Expand All @@ -97,8 +81,7 @@ export default function FormClaim({
if (file) {
setUploading(true);
try {
const compressedFile = await compressImage(file);
const cid = await retryUpload(compressedFile);
const cid = await retryUpload(file);
setImageURI(`${LINK_IPFS}/${cid}`);
} catch (error) {
console.error('Error uploading file:', error);
Expand Down

0 comments on commit f589717

Please sign in to comment.