Memoize
This commit is contained in:
@@ -55,10 +55,8 @@ export function PostEmbeds({
|
|||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
allowNestedQuotes?: boolean
|
allowNestedQuotes?: boolean
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
|
||||||
const {openLightbox} = useLightboxControls()
|
const {openLightbox} = useLightboxControls()
|
||||||
const largeAltBadge = useLargeAltBadgeEnabled()
|
const largeAltBadge = useLargeAltBadgeEnabled()
|
||||||
const moderationOpts = useModerationOpts()
|
|
||||||
|
|
||||||
// quote post with media
|
// quote post with media
|
||||||
// =
|
// =
|
||||||
@@ -77,32 +75,13 @@ export function PostEmbeds({
|
|||||||
|
|
||||||
if (AppBskyEmbedRecord.isView(embed)) {
|
if (AppBskyEmbedRecord.isView(embed)) {
|
||||||
// custom feed embed (i.e. generator view)
|
// custom feed embed (i.e. generator view)
|
||||||
// =
|
|
||||||
if (AppBskyFeedDefs.isGeneratorView(embed.record)) {
|
if (AppBskyFeedDefs.isGeneratorView(embed.record)) {
|
||||||
const moderation = moderationOpts
|
return <MaybeFeedCard view={embed.record} />
|
||||||
? moderateFeedGenerator(embed.record, moderationOpts)
|
|
||||||
: undefined
|
|
||||||
return (
|
|
||||||
<ContentHider modui={moderation?.ui('contentList')}>
|
|
||||||
<FeedSourceCard
|
|
||||||
feedUri={embed.record.uri}
|
|
||||||
style={[pal.view, pal.border, styles.customFeedOuter]}
|
|
||||||
showLikes
|
|
||||||
/>
|
|
||||||
</ContentHider>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// list embed
|
// list embed
|
||||||
if (AppBskyGraphDefs.isListView(embed.record)) {
|
if (AppBskyGraphDefs.isListView(embed.record)) {
|
||||||
const moderation = moderationOpts
|
return <MaybeListCard view={embed.record} />
|
||||||
? moderateUserList(embed.record, moderationOpts)
|
|
||||||
: undefined
|
|
||||||
return (
|
|
||||||
<ContentHider modui={moderation?.ui('contentList')}>
|
|
||||||
<ListEmbed item={embed.record} />
|
|
||||||
</ContentHider>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppBskyGraphDefs.isStarterPackViewBasic(embed.record)) {
|
if (AppBskyGraphDefs.isStarterPackViewBasic(embed.record)) {
|
||||||
@@ -200,6 +179,39 @@ export function PostEmbeds({
|
|||||||
return <View />
|
return <View />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MaybeFeedCard({view}: {view: AppBskyFeedDefs.GeneratorView}) {
|
||||||
|
const pal = usePalette('default')
|
||||||
|
const moderationOpts = useModerationOpts()
|
||||||
|
const moderation = React.useMemo(() => {
|
||||||
|
return moderationOpts
|
||||||
|
? moderateFeedGenerator(view, moderationOpts)
|
||||||
|
: undefined
|
||||||
|
}, [view, moderationOpts])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ContentHider modui={moderation?.ui('contentList')}>
|
||||||
|
<FeedSourceCard
|
||||||
|
feedUri={view.uri}
|
||||||
|
style={[pal.view, pal.border, styles.customFeedOuter]}
|
||||||
|
showLikes
|
||||||
|
/>
|
||||||
|
</ContentHider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function MaybeListCard({view}: {view: AppBskyGraphDefs.ListView}) {
|
||||||
|
const moderationOpts = useModerationOpts()
|
||||||
|
const moderation = React.useMemo(() => {
|
||||||
|
return moderationOpts ? moderateUserList(view, moderationOpts) : undefined
|
||||||
|
}, [view, moderationOpts])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ContentHider modui={moderation?.ui('contentList')}>
|
||||||
|
<ListEmbed item={view} />
|
||||||
|
</ContentHider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user