diff --git a/convex/http.ts b/convex/http.ts index a6292fe..c6595ec 100644 --- a/convex/http.ts +++ b/convex/http.ts @@ -8,13 +8,12 @@ auth.addHttpRoutes(http); http.route({ - pathPrefix: '/images/', + pathPrefix: '/', method: "GET", handler: httpAction(async (ctx, request) => { - const { url, json } = request - const { body: { storageId } } = await json(); + const { body: { storageId } } = await request.json(); - console.log(`received request.url ${url}`) + console.log(`received request.url ${request.url}`) console.log(`received request.body.storageId ${storageId}`) return new Response(null, { diff --git a/convex/users.ts b/convex/users.ts index 5b2bdd5..94148eb 100644 --- a/convex/users.ts +++ b/convex/users.ts @@ -1,5 +1,5 @@ import { v } from "convex/values"; -import { query, mutation, internalMutation } from "./_generated/server"; +import { query, mutation } from "./_generated/server"; import { auth } from "./auth"; import { users } from "./schema"; import { crud } from "convex-helpers/server"; @@ -20,23 +20,6 @@ export const viewer = query({ } }); -export const optimizeImage = internalMutation({ - args: { userId: v.id('users') }, - handler: async (ctx, args) => { - - const user = await read(ctx, { id: args.userId }); - if (!user) return null; - - // If this user has an image and is an author, optimize their image - if (user.image && !user.image.endsWith('.webp')) { - const isAuthor = (await authoredPosts(ctx, { userId: user._id })).length; - if (isAuthor) { - - } - - } - }, -}); export const authoredPosts = query({ diff --git a/src/components/Blog/Edit.tsx b/src/components/Blog/Edit.tsx index e9a11bc..d0d982d 100644 --- a/src/components/Blog/Edit.tsx +++ b/src/components/Blog/Edit.tsx @@ -16,7 +16,6 @@ import { useNavigate, useSearchParams } from "react-router-dom"; import { VersionHistory } from "@/components/Blog/History"; import { Toolbar } from "../Toolbar"; import type { Doc } from "../../../convex/_generated/dataModel"; -import { TrashIcon } from "@radix-ui/react-icons"; const versionDefaults = { postId: '', diff --git a/src/components/Inputs.tsx b/src/components/Inputs.tsx index b60f460..afab7fc 100644 --- a/src/components/Inputs.tsx +++ b/src/components/Inputs.tsx @@ -99,13 +99,13 @@ export function ImageField({ form }: CommonProps { - if (image) { - form.setValue('imageUrl' as FieldPath, + if (image?.url) { + setValue('imageUrl' as FieldPath, image.url as FieldValue, { shouldDirty: true }); } - }, [image, setValue]); + }, [image?.url, setValue]); const saveAfterUpload = async (uploaded: UploadFileResponse[]) => { const { name, type, size, response } = uploaded[0]; @@ -144,7 +144,7 @@ export function ImageField({ form }: CommonProps { toast({ title: 'Error uploading image', - description: `Error: ${error}`, + description: `Error: ${error as string}`, variant: 'destructive' }) }} @@ -154,4 +154,4 @@ export function ImageField({ form }: CommonProps ) -}; +}