feat: image compress before upload

This commit is contained in:
gosangam
2026-05-31 09:56:53 +05:30
parent 5506afa758
commit 8bd82a0e8a
10 changed files with 673 additions and 60 deletions
@@ -26,6 +26,7 @@ import {
DrawerTitle,
} from "@/components/ui/drawer";
import { posts, SocialError, type Post } from "@/lib/social";
import { compressImage } from "@/lib/compress-image";
type Busy = "upload" | "remove" | null;
@@ -69,7 +70,8 @@ export function UpdateBackgroundModal({
if (!file) return;
setBusy("upload");
try {
const url = await posts.uploadImage(file);
const compressed = await compressImage(file);
const url = await posts.uploadImage(compressed);
const updated = await posts.replaceImages(post.id, [url]);
toast.success("Background updated");
onUpdated?.(updated);