Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove browser-image-compression #431

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading