From 02e0015a6322fc9d7d62a75a9884ab32fd05b215 Mon Sep 17 00:00:00 2001 From: highperfocused Date: Sun, 13 Apr 2025 13:31:56 +0200 Subject: [PATCH] cleanup upload-component pt2 --- components/upload-component.tsx | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/components/upload-component.tsx b/components/upload-component.tsx index 232adfb..f72f822 100644 --- a/components/upload-component.tsx +++ b/components/upload-component.tsx @@ -14,6 +14,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Copy, Check, ExternalLink, FileImage, Clock, Database, ArrowLeft } from "lucide-react" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" import { Spinner } from "./spinner" +import { createHash } from "crypto" interface UploadResponse { url: string @@ -231,32 +232,7 @@ const UploadResponseView = ({ data, onReset }: { data: UploadResponse; onReset: ) } -async function calculateBlurhash(file: File): Promise { - return new Promise((resolve, reject) => { - const canvas = document.createElement("canvas") - const ctx = canvas.getContext("2d") - const img = new Image() - img.crossOrigin = "anonymous" - img.onload = () => { - canvas.width = 32 - canvas.height = 32 - ctx?.drawImage(img, 0, 0, 32, 32) - const imageData = ctx?.getImageData(0, 0, 32, 32) - if (imageData) { - // Mock blurhash calculation - in a real app you'd use the blurhash library - const mockBlurhash = "LGF5?xYk^6#M@-5c,1J5@[or[Q6." - resolve(mockBlurhash) - } else { - reject(new Error("Failed to get image data")) - } - } - img.onerror = reject - img.src = URL.createObjectURL(file) - }) -} - const UploadComponent = () => { - const { createHash } = require("crypto") const loginType = typeof window !== "undefined" ? window.localStorage.getItem("loginType") : null const [previewUrl, setPreviewUrl] = useState("") const [isLoading, setIsLoading] = useState(false)