sigh, kind of there
This commit is contained in:
@@ -6,12 +6,17 @@ import {
|
|||||||
TextStyle,
|
TextStyle,
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {ChatBskyConvoDefs, RichText as RichTextAPI} from '@atproto/api'
|
import {
|
||||||
|
AppBskyEmbedRecord,
|
||||||
|
ChatBskyConvoDefs,
|
||||||
|
RichText as RichTextAPI,
|
||||||
|
} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {ConvoItem} from '#/state/messages/convo/types'
|
import {ConvoItem} from '#/state/messages/convo/types'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
|
import {PostEmbeds} from 'view/com/util/post-embeds'
|
||||||
import {TimeElapsed} from 'view/com/util/TimeElapsed'
|
import {TimeElapsed} from 'view/com/util/TimeElapsed'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {ActionsWrapper} from '#/components/dms/ActionsWrapper'
|
import {ActionsWrapper} from '#/components/dms/ActionsWrapper'
|
||||||
@@ -107,6 +112,11 @@ let MessageItem = ({
|
|||||||
interactiveStyle={a.underline}
|
interactiveStyle={a.underline}
|
||||||
enableTags
|
enableTags
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{item.message.embed &&
|
||||||
|
AppBskyEmbedRecord.isView(item.message.embed) && (
|
||||||
|
<PostEmbeds embed={item.message.embed} moderation={undefined} />
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</ActionsWrapper>
|
</ActionsWrapper>
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {AppBskyEmbedRecord, AppBskyRichtextFacet, RichText} from '@atproto/api'
|
|||||||
import {PostView} from '@atproto/api/dist/client/types/app/bsky/feed/defs'
|
import {PostView} from '@atproto/api/dist/client/types/app/bsky/feed/defs'
|
||||||
|
|
||||||
import {shortenLinks} from '#/lib/strings/rich-text-manip'
|
import {shortenLinks} from '#/lib/strings/rich-text-manip'
|
||||||
import {logger} from '#/logger'
|
|
||||||
import {isIOS, isNative} from '#/platform/detection'
|
import {isIOS, isNative} from '#/platform/detection'
|
||||||
import {isConvoActive, useConvoActive} from '#/state/messages/convo'
|
import {isConvoActive, useConvoActive} from '#/state/messages/convo'
|
||||||
import {ConvoItem, ConvoStatus} from '#/state/messages/convo/types'
|
import {ConvoItem, ConvoStatus} from '#/state/messages/convo/types'
|
||||||
@@ -274,7 +273,7 @@ export function MessagesList({
|
|||||||
await rt.detectFacets(getAgent())
|
await rt.detectFacets(getAgent())
|
||||||
rt = shortenLinks(rt)
|
rt = shortenLinks(rt)
|
||||||
|
|
||||||
const {facets, embed} = handleFacets(rt, getPost)
|
const {facets, embed} = await handleFacets(rt, getPost)
|
||||||
|
|
||||||
if (!hasScrolled) {
|
if (!hasScrolled) {
|
||||||
setHasScrolled(true)
|
setHasScrolled(true)
|
||||||
@@ -368,7 +367,7 @@ export function MessagesList({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFacets(
|
async function handleFacets(
|
||||||
rt: RichText,
|
rt: RichText,
|
||||||
getPost: ({uri}: {uri: string}) => Promise<PostView>,
|
getPost: ({uri}: {uri: string}) => Promise<PostView>,
|
||||||
) {
|
) {
|
||||||
@@ -376,18 +375,17 @@ function handleFacets(
|
|||||||
let embed: AppBskyEmbedRecord.Main | undefined
|
let embed: AppBskyEmbedRecord.Main | undefined
|
||||||
if (rt.facets) {
|
if (rt.facets) {
|
||||||
for (const facet of rt.facets) {
|
for (const facet of rt.facets) {
|
||||||
if (AppBskyRichtextFacet.isMention(facet)) {
|
let skip = false
|
||||||
if (facet.did) {
|
for (const feature of facet.features) {
|
||||||
facets.push(facet)
|
if (AppBskyRichtextFacet.isMention(feature)) {
|
||||||
}
|
if (!feature.did) {
|
||||||
} else {
|
skip = true
|
||||||
if (
|
break
|
||||||
AppBskyRichtextFacet.isLink(facet) &&
|
}
|
||||||
isBskyPostUrl(facet.uri) &&
|
} else if (AppBskyRichtextFacet.isLink(feature)) {
|
||||||
!embed
|
if (isBskyPostUrl(feature.uri)) {
|
||||||
) {
|
const post = await getPostAsQuote(getPost, feature.uri)
|
||||||
getPostAsQuote(getPost, facet.uri).then(
|
if (post) {
|
||||||
post => {
|
|
||||||
embed = {
|
embed = {
|
||||||
$type: 'app.bsky.embed.record',
|
$type: 'app.bsky.embed.record',
|
||||||
record: {
|
record: {
|
||||||
@@ -395,14 +393,12 @@ function handleFacets(
|
|||||||
cid: post.cid,
|
cid: post.cid,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
err => {
|
}
|
||||||
logger.error('Failed to fetch post for quote embedding', {
|
|
||||||
message: err.toString(),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!skip) {
|
||||||
facets.push(facet)
|
facets.push(facet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user