From dd9c817cc8d039c333155a1a59699be77c2efbc8 Mon Sep 17 00:00:00 2001 From: vineyardbovines Date: Tue, 28 Jul 2026 12:57:56 -0400 Subject: [PATCH] Fix GIF post gallery spacing --- .../maybeApplyGalleryOffsetStyles.test.ts | 39 +++++++++++++++++++ .../Gallery/maybeApplyGalleryOffsetStyles.ts | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/components/images/Gallery/maybeApplyGalleryOffsetStyles.test.ts diff --git a/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.test.ts b/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.test.ts new file mode 100644 index 0000000000..19651c503d --- /dev/null +++ b/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.test.ts @@ -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() + }) +}) diff --git a/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.ts b/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.ts index 6ac2c0086f..eea54b5ed9 100644 --- a/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.ts +++ b/src/components/images/Gallery/maybeApplyGalleryOffsetStyles.ts @@ -88,6 +88,7 @@ export function maybeApplyGalleryOffsetStyles( if (!isPostGalleryEmbedEnabled) return // one image, not a gallery if (embed.media.images.length === 1) return + hasImages = true } if ( bsky.dangerousIsType( @@ -97,8 +98,8 @@ export function maybeApplyGalleryOffsetStyles( ) { // single (or empty) gallery - no offset needed if (embed.media.items.length <= 1) return + hasImages = true } - hasImages = true } if (!hasImages) return