af2eec0f84
- Composer.tsx: thread gallery through reply pills (hasMedia), post:create/draft:save analytics, missingAltError, and publish-fail logger annotation - composer/state/composer.ts: surface a logger.warn when embed_add_images would exceed MAX_GALLERY_IMAGES (hard slice preserved); ascii-only comments - maybeApplyGalleryOffsetStyles.ts: scope PostGalleryEmbedEnable gate to image-embed branches so gallery posts always get no-content offsets - MessageOverlays.tsx: store reactionsTargetId instead of a frozen message snapshot; look up the live message each render. Memoize reportSubject on reportTarget+convoId so ReportDialog's parseReportSubject memo survives convo updates. Replace open-after-mount boolean with a ref keyed to id so reopening the same message reliably re-triggers - ImageEmbed.tsx + ImageLayoutGrid.tsx: thread isWithinQuote through the 2-4 image fallthrough; explicit prop overrides the viewContext heuristic - parseReportSubject.ts: flip the image attribute true for gallery embeds (top-level and post_with_media), matching the existing images branches - AppIconSettings/index.tsx: restore the IconName casts the previous change dropped; IconName is still a literal union - composer/photos/Gallery.tsx: wrap to a 4-column grid for n>4 so 10-image previews don't crush remove/alt-text controls - lib/api/index.ts: normalize gallery upload log nouns to image/images
110 lines
2.8 KiB
TypeScript
110 lines
2.8 KiB
TypeScript
import {
|
|
AppBskyActorDefs,
|
|
AppBskyFeedDefs,
|
|
AppBskyFeedPost,
|
|
AppBskyGraphDefs,
|
|
} from '@atproto/api'
|
|
|
|
import {
|
|
type ParsedReportSubject,
|
|
type ReportSubject,
|
|
} from '#/components/moderation/ReportDialog/types'
|
|
import * as bsky from '#/types/bsky'
|
|
|
|
export function parseReportSubject(
|
|
subject: ReportSubject,
|
|
): ParsedReportSubject | undefined {
|
|
if (!subject) return
|
|
|
|
if ('convoId' in subject) {
|
|
if ('message' in subject) {
|
|
return {
|
|
type: 'convoMessage',
|
|
...subject,
|
|
}
|
|
}
|
|
return {
|
|
type: 'convo',
|
|
convoId: subject.convoId,
|
|
did: subject.did,
|
|
}
|
|
}
|
|
|
|
if (
|
|
AppBskyActorDefs.isProfileViewBasic(subject) ||
|
|
AppBskyActorDefs.isProfileView(subject) ||
|
|
AppBskyActorDefs.isProfileViewDetailed(subject)
|
|
) {
|
|
return {
|
|
type: 'account',
|
|
did: subject.did,
|
|
nsid: 'app.bsky.actor.profile',
|
|
}
|
|
} else if (AppBskyActorDefs.isStatusView(subject)) {
|
|
if (!subject.uri || !subject.cid) return
|
|
return {
|
|
type: 'status',
|
|
uri: subject.uri,
|
|
cid: subject.cid,
|
|
nsid: 'app.bsky.actor.status',
|
|
}
|
|
} else if (AppBskyGraphDefs.isListView(subject)) {
|
|
return {
|
|
type: 'list',
|
|
uri: subject.uri,
|
|
cid: subject.cid,
|
|
nsid: 'app.bsky.graph.list',
|
|
}
|
|
} else if (AppBskyFeedDefs.isGeneratorView(subject)) {
|
|
return {
|
|
type: 'feed',
|
|
uri: subject.uri,
|
|
cid: subject.cid,
|
|
nsid: 'app.bsky.feed.generator',
|
|
}
|
|
} else if (AppBskyGraphDefs.isStarterPackView(subject)) {
|
|
return {
|
|
type: 'starterPack',
|
|
uri: subject.uri,
|
|
cid: subject.cid,
|
|
nsid: 'app.bsky.graph.starterPack',
|
|
}
|
|
} else if (AppBskyFeedDefs.isPostView(subject)) {
|
|
const record = subject.record
|
|
const embed = bsky.post.parseEmbed(subject.embed)
|
|
if (
|
|
bsky.dangerousIsType<AppBskyFeedPost.Record>(
|
|
record,
|
|
AppBskyFeedPost.isRecord,
|
|
)
|
|
) {
|
|
return {
|
|
type: 'post',
|
|
uri: subject.uri,
|
|
cid: subject.cid,
|
|
nsid: 'app.bsky.feed.post',
|
|
attributes: {
|
|
reply: !!record.reply,
|
|
image:
|
|
embed.type === 'images' ||
|
|
embed.type === 'gallery' ||
|
|
(embed.type === 'post_with_media' &&
|
|
(embed.media.type === 'images' ||
|
|
embed.media.type === 'gallery')),
|
|
video:
|
|
embed.type === 'video' ||
|
|
(embed.type === 'post_with_media' && embed.media.type === 'video'),
|
|
link:
|
|
embed.type === 'link' ||
|
|
(embed.type === 'post_with_media' && embed.media.type === 'link'),
|
|
quote:
|
|
embed.type === 'post' ||
|
|
(embed.type === 'post_with_media' &&
|
|
(embed.view.type === 'post' ||
|
|
embed.view.type === 'post_with_media')),
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|