From c6eef2e4a6fb1da0ded302a3677b2531145ff580 Mon Sep 17 00:00:00 2001 From: yukigesho Date: Thu, 19 Dec 2024 21:47:31 -0800 Subject: [PATCH] feat: Remove `browser-image-compression` --- package.json | 1 - pnpm-lock.yaml | 21 +++------------------ src/components/global/FormClaim.tsx | 19 +------------------ 3 files changed, 4 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 727e81c..834c21a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ab8c4eb..d274102 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,9 +38,6 @@ importers: axios: specifier: ^1.6.8 version: 1.7.2 - browser-image-compression: - specifier: ^2.0.2 - version: 2.0.2 clsx: specifier: ^2.0.0 version: 2.1.1 @@ -3213,9 +3210,6 @@ packages: brorand@1.1.0: resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - browser-image-compression@2.0.2: - resolution: {integrity: sha512-pBLlQyUf6yB8SmmngrcOw3EoS4RpQ1BcylI3T9Yqn7+4nrQTXJD4sJDe5ODnJdrvNMaio5OicFo75rDyJD2Ucw==} - browser-process-hrtime@1.0.0: resolution: {integrity: sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==} @@ -7045,9 +7039,6 @@ packages: resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} hasBin: true - uzip@0.20201231.0: - resolution: {integrity: sha512-OZeJfZP+R0z9D6TmBgLq2LHzSSptGMGDGigGiEe0pr8UBe/7fdflgHlHBNDASTXB5jnFuxHpNaJywSg8YFeGng==} - v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -7467,7 +7458,7 @@ snapshots: '@babel/traverse': 7.25.9(supports-color@8.1.1) '@babel/types': 7.26.0 convert-source-map: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.7(supports-color@8.1.1) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -8786,7 +8777,7 @@ snapshots: '@babel/parser': 7.26.1 '@babel/template': 7.25.9 '@babel/types': 7.26.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.7(supports-color@8.1.1) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -9583,7 +9574,7 @@ snapshots: dependencies: '@ethereumjs/tx': 4.2.0 '@types/debug': 4.1.12 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.7(supports-color@8.1.1) semver: 7.6.2 superstruct: 1.0.4 transitivePeerDependencies: @@ -11525,10 +11516,6 @@ snapshots: brorand@1.1.0: {} - browser-image-compression@2.0.2: - dependencies: - uzip: 0.20201231.0 - browser-process-hrtime@1.0.0: {} browserslist@4.23.0: @@ -16071,8 +16058,6 @@ snapshots: uuid@9.0.1: {} - uzip@0.20201231.0: {} - v8-compile-cache-lib@3.0.1: {} v8-to-istanbul@8.1.1: diff --git a/src/components/global/FormClaim.tsx b/src/components/global/FormClaim.tsx index fc021ac..7a97e09 100644 --- a/src/components/global/FormClaim.tsx +++ b/src/components/global/FormClaim.tsx @@ -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'; @@ -56,21 +55,6 @@ export default function FormClaim({ const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop }); - const compressImage = async (image: File): Promise => { - 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 => { const MAX_RETRIES = 6; const RETRY_DELAY = 3000; @@ -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);