From 246278ed8597220842c06b61652a09dbaf4ae8da Mon Sep 17 00:00:00 2001 From: Florian <45694132+flo-bit@users.noreply.github.com> Date: Fri, 23 Jan 2026 17:53:08 +0100 Subject: [PATCH] fix image upload --- docs/Beta.md | 4 ---- src/lib/atproto/methods.ts | 11 +++++++---- src/lib/cards/ImageCard/index.ts | 2 +- src/lib/cards/VideoCard/index.ts | 2 +- src/lib/website/load.ts | 12 ++++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/Beta.md b/docs/Beta.md index 54122a9..9f4879a 100644 --- a/docs/Beta.md +++ b/docs/Beta.md @@ -6,8 +6,6 @@ - move subpages to own lexicon (app.blento.page) - move description to markdownDescription and set description as text only -- fix recent blentos only showing the last ~5 blentos - - card with big call to action button - link card: save favicon and og image as blobs @@ -20,8 +18,6 @@ - allow setting base and accent color -- go straight to edit mode (and redirect to edit mode on succesfull login) - - ask to fill with some default cards on page creation - share button (copy share link to blento, maybe post to bluesky?) diff --git a/src/lib/atproto/methods.ts b/src/lib/atproto/methods.ts index ef31a11..d6e2f60 100644 --- a/src/lib/atproto/methods.ts +++ b/src/lib/atproto/methods.ts @@ -229,13 +229,15 @@ export async function uploadBlob({ blob }: { blob: Blob }) { if (!user.did || !user.client) throw new Error("Can't upload blob: Not logged in"); const blobResponse = await user.client.post('com.atproto.repo.uploadBlob', { - params: { + input: blob, + data: { repo: user.did - }, - input: blob + } }); - if (!blobResponse?.ok) return; + if (!blobResponse?.ok) { + return; + } const blobInfo = blobResponse?.data.blob as { $type: 'blob'; @@ -294,6 +296,7 @@ export function getImageBlobUrl({ }; }; }) { + if (!did || !blob?.ref?.$link) return ''; return `https://cdn.bsky.app/img/feed_thumbnail/plain/${did}/${blob.ref.$link}@jpeg`; } diff --git a/src/lib/cards/ImageCard/index.ts b/src/lib/cards/ImageCard/index.ts index dc9fb6b..f68290c 100644 --- a/src/lib/cards/ImageCard/index.ts +++ b/src/lib/cards/ImageCard/index.ts @@ -16,7 +16,7 @@ export const ImageCardDefinition = { }, upload: async (item) => { if (item.cardData.blob) { - item.cardData.image = await uploadBlob(item.cardData.blob); + item.cardData.image = await uploadBlob({ blob: item.cardData.blob }); delete item.cardData.blob; } diff --git a/src/lib/cards/VideoCard/index.ts b/src/lib/cards/VideoCard/index.ts index 91ee648..c969ec1 100644 --- a/src/lib/cards/VideoCard/index.ts +++ b/src/lib/cards/VideoCard/index.ts @@ -39,7 +39,7 @@ export const VideoCardDefinition = { if (item.cardData.blob) { const blob = item.cardData.blob; const aspectRatio = await getAspectRatio(blob); - const uploadedBlob = await uploadBlob(blob); + const uploadedBlob = await uploadBlob({ blob }); item.cardData.video = { $type: 'app.bsky.embed.video', diff --git a/src/lib/website/load.ts b/src/lib/website/load.ts index 2f8e127..47cc1a2 100644 --- a/src/lib/website/load.ts +++ b/src/lib/website/load.ts @@ -88,14 +88,14 @@ export async function loadData( if (!cardDef?.loadData) continue; - additionDataPromises[cardType] = cardDef - .loadData( + try { + additionDataPromises[cardType] = cardDef.loadData( cards.filter((v) => cardType === v.value.cardType).map((v) => v.value) as Item[], loadOptions - ) - .catch((error: Error) => { - console.error('error getting additional data for', cardType, error); - }); + ); + } catch { + console.error('error getting additional data for', cardType); + } } await Promise.all(Object.values(additionDataPromises)); -- 2.51.2