Merge main into gallery-embed, migrate off local shim
Bumps @atproto/api to 0.20.9, which ships the generated `AppBskyEmbedGallery` namespace and `DraftPost.embedGallery`. Swaps every `#/lib/api/gallery-embed-shim` import to `@atproto/api`, deletes the shim, drops the local `DraftPostWithGallery` widen-types, and adds the narrowing calls (`isViewImage`, `isDraftEmbedImage`) the real lexicon unions require. The merge also auto-resolves an inline image-restore block in `drafts/state/api.ts` against main's typing tweak — main switched to `satisfies ComposerImage` and `NonNullable<typeof img>`, which here move into the existing `restoreDraftImages` helper that's now shared by both the images and gallery restore paths.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
type $Typed,
|
||||
type AppBskyEmbedExternal,
|
||||
type AppBskyEmbedGallery,
|
||||
type AppBskyEmbedImages,
|
||||
type AppBskyEmbedRecord,
|
||||
type AppBskyEmbedRecordWithMedia,
|
||||
@@ -21,7 +22,6 @@ import {sha256} from 'js-sha256'
|
||||
import {CID} from 'multiformats/cid'
|
||||
import * as Hasher from 'multiformats/hashes/hasher'
|
||||
|
||||
import {type AppBskyEmbedGallery} from '#/lib/api/gallery-embed-shim'
|
||||
import {isNetworkError} from '#/lib/strings/errors'
|
||||
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
|
||||
import {logger} from '#/logger'
|
||||
@@ -347,14 +347,14 @@ async function resolveMedia(
|
||||
count: imagesDraft.length,
|
||||
})
|
||||
onStateChange?.(t`Uploading images...`)
|
||||
const items: AppBskyEmbedGallery.Image[] = await Promise.all(
|
||||
const items: $Typed<AppBskyEmbedGallery.Image>[] = await Promise.all(
|
||||
imagesDraft.map(async (image, i) => {
|
||||
logger.debug(`Compressing gallery image #${i}`)
|
||||
const {path, width, height, mime} = await compressImage(image)
|
||||
logger.debug(`Uploading gallery image #${i}`)
|
||||
const res = await uploadBlob(agent, path, mime)
|
||||
return {
|
||||
$type: 'app.bsky.embed.gallery#image',
|
||||
$type: 'app.bsky.embed.gallery#image' as const,
|
||||
image: res.data.blob,
|
||||
alt: image.alt,
|
||||
aspectRatio: {width, height},
|
||||
|
||||
Reference in New Issue
Block a user