Store QP authors in the DID cache (#3509)

* store qp author in did cache

* organize

* this seems nicer

* move outside of jsx
zio/stable
Hailey 2024-04-12 12:53:48 -07:00 committed by GitHub
parent 835f2e6548
commit 44039c68d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 18 deletions

View File

@ -1,31 +1,34 @@
import React from 'react' import React from 'react'
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native' import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
import { import {
AppBskyFeedDefs,
AppBskyEmbedRecord,
AppBskyFeedPost,
AppBskyEmbedImages,
AppBskyEmbedRecordWithMedia,
AppBskyEmbedExternal, AppBskyEmbedExternal,
RichText as RichTextAPI, AppBskyEmbedImages,
AppBskyEmbedRecord,
AppBskyEmbedRecordWithMedia,
AppBskyFeedDefs,
AppBskyFeedPost,
moderatePost, moderatePost,
ModerationDecision, ModerationDecision,
RichText as RichTextAPI,
} from '@atproto/api' } from '@atproto/api'
import {AtUri} from '@atproto/api' import {AtUri} from '@atproto/api'
import {PostMeta} from '../PostMeta'
import {Link} from '../Link'
import {Text} from '../text/Text'
import {usePalette} from 'lib/hooks/usePalette'
import {ComposerOptsQuote} from 'state/shell/composer'
import {PostEmbeds} from '.'
import {PostAlerts} from '../../../../components/moderation/PostAlerts'
import {makeProfileLink} from 'lib/routes/links'
import {InfoCircleIcon} from 'lib/icons'
import {Trans} from '@lingui/macro' import {Trans} from '@lingui/macro'
import {useQueryClient} from '@tanstack/react-query'
import {useModerationOpts} from '#/state/queries/preferences' import {useModerationOpts} from '#/state/queries/preferences'
import {ContentHider} from '../../../../components/moderation/ContentHider' import {RQKEY as RQKEY_URI} from '#/state/queries/resolve-uri'
import {RichText} from '#/components/RichText' import {usePalette} from 'lib/hooks/usePalette'
import {InfoCircleIcon} from 'lib/icons'
import {makeProfileLink} from 'lib/routes/links'
import {ComposerOptsQuote} from 'state/shell/composer'
import {atoms as a} from '#/alf' import {atoms as a} from '#/alf'
import {RichText} from '#/components/RichText'
import {ContentHider} from '../../../../components/moderation/ContentHider'
import {PostAlerts} from '../../../../components/moderation/PostAlerts'
import {Link} from '../Link'
import {PostMeta} from '../PostMeta'
import {Text} from '../text/Text'
import {PostEmbeds} from '.'
export function MaybeQuoteEmbed({ export function MaybeQuoteEmbed({
embed, embed,
@ -107,6 +110,7 @@ export function QuoteEmbed({
moderation?: ModerationDecision moderation?: ModerationDecision
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
}) { }) {
const queryClient = useQueryClient()
const pal = usePalette('default') const pal = usePalette('default')
const itemUrip = new AtUri(quote.uri) const itemUrip = new AtUri(quote.uri)
const itemHref = makeProfileLink(quote.author, 'post', itemUrip.rkey) const itemHref = makeProfileLink(quote.author, 'post', itemUrip.rkey)
@ -134,13 +138,18 @@ export function QuoteEmbed({
} }
}, [quote.embeds]) }, [quote.embeds])
const onBeforePress = React.useCallback(() => {
queryClient.setQueryData(RQKEY_URI(quote.author.handle), quote.author.did)
}, [queryClient, quote.author.did, quote.author.handle])
return ( return (
<ContentHider modui={moderation?.ui('contentList')}> <ContentHider modui={moderation?.ui('contentList')}>
<Link <Link
style={[styles.container, pal.borderDark, style]} style={[styles.container, pal.borderDark, style]}
hoverStyle={{borderColor: pal.colors.borderLinkHover}} hoverStyle={{borderColor: pal.colors.borderLinkHover}}
href={itemHref} href={itemHref}
title={itemTitle}> title={itemTitle}
onBeforePress={onBeforePress}>
<View pointerEvents="none"> <View pointerEvents="none">
<PostMeta <PostMeta
author={quote.author} author={quote.author}