Fix GIF post gallery spacing

This commit is contained in:
vineyardbovines
2026-07-28 12:57:56 -04:00
parent 8263175a03
commit dd9c817cc8
2 changed files with 41 additions and 1 deletions
@@ -0,0 +1,39 @@
import {type AppBskyFeedDefs, type ModerationUI} from '@atproto/api'
import {maybeApplyGalleryOffsetStyles} from './maybeApplyGalleryOffsetStyles'
describe('maybeApplyGalleryOffsetStyles', () => {
it('does not offset a record with external media', () => {
const post = {
record: {
$type: 'app.bsky.feed.post',
createdAt: '2026-07-28T01:02:03.957Z',
text: '',
embed: {
$type: 'app.bsky.embed.recordWithMedia',
media: {
$type: 'app.bsky.embed.external',
external: {
description: 'A GIF',
title: 'Let Them Fight',
uri: 'https://example.com/image.gif',
},
},
record: {
$type: 'app.bsky.embed.record',
record: {
cid: 'bafyrei',
uri: 'at://did:plc:example/app.bsky.feed.post/example',
},
},
},
},
} as unknown as AppBskyFeedDefs.PostView
const modui = {} as ModerationUI
expect(maybeApplyGalleryOffsetStyles('meta', {post, modui})).toBeUndefined()
expect(
maybeApplyGalleryOffsetStyles('embed', {post, modui}),
).toBeUndefined()
})
})
@@ -88,6 +88,7 @@ export function maybeApplyGalleryOffsetStyles(
if (!isPostGalleryEmbedEnabled) return if (!isPostGalleryEmbedEnabled) return
// one image, not a gallery // one image, not a gallery
if (embed.media.images.length === 1) return if (embed.media.images.length === 1) return
hasImages = true
} }
if ( if (
bsky.dangerousIsType<AppBskyEmbedGallery.Main>( bsky.dangerousIsType<AppBskyEmbedGallery.Main>(
@@ -97,8 +98,8 @@ export function maybeApplyGalleryOffsetStyles(
) { ) {
// single (or empty) gallery - no offset needed // single (or empty) gallery - no offset needed
if (embed.media.items.length <= 1) return if (embed.media.items.length <= 1) return
hasImages = true
} }
hasImages = true
} }
if (!hasImages) return if (!hasImages) return