Include hydrated responses for other records (#5646)

* Include hydrated responses for other records

* Rename meta -> view

This is actually all it is now.
This commit is contained in:
dan
2024-10-24 20:43:00 +01:00
committed by GitHub
parent e8a53dcea8
commit 3327c47957
4 changed files with 53 additions and 37 deletions
+22 -6
View File
@@ -1,6 +1,8 @@
import React from 'react'
import {StyleProp, View, ViewStyle} from 'react-native'
import {AppBskyGraphStarterpack} from '@atproto/api'
import {ResolvedLink} from '#/lib/api/resolve'
import {cleanError} from '#/lib/strings/errors'
import {
useResolveGifQuery,
@@ -75,12 +77,7 @@ export const ExternalEmbedLink = ({
const linkInfo = React.useMemo(
() =>
data && {
title:
data.type === 'external'
? data.title
: data.kind === 'other'
? data.meta.title
: uri,
title: getExternalLinkTitle(data) ?? uri,
uri,
description: data.type === 'external' ? data.description : '',
thumb: data.type === 'external' ? data.thumb?.source.path : undefined,
@@ -137,3 +134,22 @@ function Container({
</View>
)
}
function getExternalLinkTitle(link: ResolvedLink): string | undefined {
if (link.type === 'external') {
return link.title
}
switch (link.kind) {
// These are currently treated as external.
// TODO: Display them as embeds instead.
case 'feed':
return link.view.displayName
case 'list':
return link.view.name
case 'starter-pack':
const record = link.view.record
return AppBskyGraphStarterpack.isRecord(record)
? record.name
: 'Starter Pack'
}
}
+1 -1
View File
@@ -284,7 +284,7 @@ export function LazyQuoteEmbed({uri}: {uri: string}) {
if (!data || data.type !== 'record' || data.kind !== 'post') {
return null
}
return <QuoteEmbed quote={data.meta} />
return <QuoteEmbed quote={data.view} />
}
function viewRecordToPostView(