45f0f7eefe
* Direct port of embeds to new arch (cherry picked from commit cc3fa1f6cea396dd9222486c633a508bfee1ecd6) * Re-org * Split out ListEmbed and FeedEmbed * Split out ImageEmbed * DRY up a bit * Port over ExternalLinkEmbed * Port over Player and Gif embeds * Migrate ComposerReplyTo * Replace other usages of old post-embeds * Migrate view contexts * Copy pasta VideoEmbed * Copy pasta GifEmbed * Swap in new file location * Clean up * Fix up native * Add back in correct moderation on List and Feed embeds * Format * Prettier * delete old video utils * move bandwidth-estimate.ts * Remove log * Add LazyQuoteEmbed for composer use * Clean up unused things * Remove remaining items * Prettier * Fix imports * Handle nested quotes same as prod * Add back silenced error handling * Fix lint --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import React from 'react'
|
|
import {useWindowDimensions, View} from 'react-native'
|
|
import {type $Typed, type AppBskyEmbedRecord} from '@atproto/api'
|
|
|
|
import {atoms as a, native, tokens, useTheme, web} from '#/alf'
|
|
import {PostEmbedViewContext} from '#/components/Post/Embed'
|
|
import {Embed} from '#/components/Post/Embed'
|
|
import {MessageContextProvider} from './MessageContext'
|
|
|
|
let MessageItemEmbed = ({
|
|
embed,
|
|
}: {
|
|
embed: $Typed<AppBskyEmbedRecord.View>
|
|
}): React.ReactNode => {
|
|
const t = useTheme()
|
|
const screen = useWindowDimensions()
|
|
|
|
return (
|
|
<MessageContextProvider>
|
|
<View
|
|
style={[
|
|
a.my_xs,
|
|
t.atoms.bg,
|
|
a.rounded_md,
|
|
native({
|
|
flexBasis: 0,
|
|
width: Math.min(screen.width, 600) / 1.4,
|
|
}),
|
|
web({
|
|
width: '100%',
|
|
minWidth: 280,
|
|
maxWidth: 360,
|
|
}),
|
|
]}>
|
|
<View style={{marginTop: tokens.space.sm * -1}}>
|
|
<Embed
|
|
embed={embed}
|
|
allowNestedQuotes
|
|
viewContext={PostEmbedViewContext.Feed}
|
|
/>
|
|
</View>
|
|
</View>
|
|
</MessageContextProvider>
|
|
)
|
|
}
|
|
MessageItemEmbed = React.memo(MessageItemEmbed)
|
|
export {MessageItemEmbed}
|