custom feed embed
parent
760b5309e0
commit
c24389df87
|
@ -1,15 +1,21 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleSheet, View} from 'react-native'
|
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
|
||||||
import {Text} from '../util/text/Text'
|
import {Text} from '../util/text/Text'
|
||||||
import {AppBskyFeedDefs} from '@atproto/api'
|
import {AppBskyFeedDefs} from '@atproto/api'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {s} from 'lib/styles'
|
import {s} from 'lib/styles'
|
||||||
import {UserAvatar} from '../util/UserAvatar'
|
import {UserAvatar} from '../util/UserAvatar'
|
||||||
|
|
||||||
const AlgoItem = ({item}: {item: AppBskyFeedDefs.GeneratorView}) => {
|
const AlgoItem = ({
|
||||||
|
item,
|
||||||
|
style,
|
||||||
|
}: {
|
||||||
|
item: AppBskyFeedDefs.GeneratorView
|
||||||
|
style?: StyleProp<ViewStyle>
|
||||||
|
}) => {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container]} key={item.uri}>
|
<View style={[styles.container, style]} key={item.uri}>
|
||||||
<View style={[styles.headerContainer]}>
|
<View style={[styles.headerContainer]}>
|
||||||
<View style={[s.mr20]}>
|
<View style={[s.mr20]}>
|
||||||
<UserAvatar size={56} avatar={item.avatar} />
|
<UserAvatar size={56} avatar={item.avatar} />
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
AppBskyEmbedRecord,
|
AppBskyEmbedRecord,
|
||||||
AppBskyEmbedRecordWithMedia,
|
AppBskyEmbedRecordWithMedia,
|
||||||
AppBskyFeedPost,
|
AppBskyFeedPost,
|
||||||
|
AppBskyFeedDefs,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {Link} from '../Link'
|
import {Link} from '../Link'
|
||||||
import {ImageLayoutGrid} from '../images/ImageLayoutGrid'
|
import {ImageLayoutGrid} from '../images/ImageLayoutGrid'
|
||||||
|
@ -24,6 +25,7 @@ import {ExternalLinkEmbed} from './ExternalLinkEmbed'
|
||||||
import {getYoutubeVideoId} from 'lib/strings/url-helpers'
|
import {getYoutubeVideoId} from 'lib/strings/url-helpers'
|
||||||
import QuoteEmbed from './QuoteEmbed'
|
import QuoteEmbed from './QuoteEmbed'
|
||||||
import {AutoSizedImage} from '../images/AutoSizedImage'
|
import {AutoSizedImage} from '../images/AutoSizedImage'
|
||||||
|
import AlgoItem from 'view/com/algos/AlgoItem'
|
||||||
|
|
||||||
type Embed =
|
type Embed =
|
||||||
| AppBskyEmbedRecord.View
|
| AppBskyEmbedRecord.View
|
||||||
|
@ -42,6 +44,8 @@ export function PostEmbeds({
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
|
|
||||||
|
// quote post with media
|
||||||
|
// =
|
||||||
if (
|
if (
|
||||||
AppBskyEmbedRecordWithMedia.isView(embed) &&
|
AppBskyEmbedRecordWithMedia.isView(embed) &&
|
||||||
AppBskyEmbedRecord.isViewRecord(embed.record.record) &&
|
AppBskyEmbedRecord.isViewRecord(embed.record.record) &&
|
||||||
|
@ -65,6 +69,8 @@ export function PostEmbeds({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// quote post
|
||||||
|
// =
|
||||||
if (AppBskyEmbedRecord.isView(embed)) {
|
if (AppBskyEmbedRecord.isView(embed)) {
|
||||||
if (
|
if (
|
||||||
AppBskyEmbedRecord.isViewRecord(embed.record) &&
|
AppBskyEmbedRecord.isViewRecord(embed.record) &&
|
||||||
|
@ -87,6 +93,8 @@ export function PostEmbeds({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// image embed
|
||||||
|
// =
|
||||||
if (AppBskyEmbedImages.isView(embed)) {
|
if (AppBskyEmbedImages.isView(embed)) {
|
||||||
const {images} = embed
|
const {images} = embed
|
||||||
|
|
||||||
|
@ -132,10 +140,11 @@ export function PostEmbeds({
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// external link embed
|
||||||
|
// =
|
||||||
if (AppBskyEmbedExternal.isView(embed)) {
|
if (AppBskyEmbedExternal.isView(embed)) {
|
||||||
const link = embed.external
|
const link = embed.external
|
||||||
const youtubeVideoId = getYoutubeVideoId(link.uri)
|
const youtubeVideoId = getYoutubeVideoId(link.uri)
|
||||||
|
@ -153,6 +162,21 @@ export function PostEmbeds({
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// custom feed embed (i.e. generator view)
|
||||||
|
// =
|
||||||
|
if (
|
||||||
|
AppBskyEmbedRecord.isView(embed) &&
|
||||||
|
AppBskyFeedDefs.isGeneratorView(embed.record)
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<AlgoItem
|
||||||
|
item={embed.record}
|
||||||
|
style={[pal.view, pal.border, styles.extOuter]}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return <View />
|
return <View />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue