Skip to content

Commit

Permalink
Store QP authors in the DID cache (#3509)
Browse files Browse the repository at this point in the history
* store qp author in did cache

* organize

* this seems nicer

* move outside of jsx
  • Loading branch information
haileyok authored Apr 12, 2024
1 parent 835f2e6 commit 44039c6
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions src/view/com/util/post-embeds/QuoteEmbed.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import React from 'react'
import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
import {
AppBskyFeedDefs,
AppBskyEmbedRecord,
AppBskyFeedPost,
AppBskyEmbedExternal,
AppBskyEmbedImages,
AppBskyEmbedRecord,
AppBskyEmbedRecordWithMedia,
AppBskyEmbedExternal,
RichText as RichTextAPI,
AppBskyFeedDefs,
AppBskyFeedPost,
moderatePost,
ModerationDecision,
RichText as RichTextAPI,
} 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 {useQueryClient} from '@tanstack/react-query'

import {useModerationOpts} from '#/state/queries/preferences'
import {ContentHider} from '../../../../components/moderation/ContentHider'
import {RichText} from '#/components/RichText'
import {RQKEY as RQKEY_URI} from '#/state/queries/resolve-uri'
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 {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({
embed,
Expand Down Expand Up @@ -107,6 +110,7 @@ export function QuoteEmbed({
moderation?: ModerationDecision
style?: StyleProp<ViewStyle>
}) {
const queryClient = useQueryClient()
const pal = usePalette('default')
const itemUrip = new AtUri(quote.uri)
const itemHref = makeProfileLink(quote.author, 'post', itemUrip.rkey)
Expand Down Expand Up @@ -134,13 +138,18 @@ export function QuoteEmbed({
}
}, [quote.embeds])

const onBeforePress = React.useCallback(() => {
queryClient.setQueryData(RQKEY_URI(quote.author.handle), quote.author.did)
}, [queryClient, quote.author.did, quote.author.handle])

return (
<ContentHider modui={moderation?.ui('contentList')}>
<Link
style={[styles.container, pal.borderDark, style]}
hoverStyle={{borderColor: pal.colors.borderLinkHover}}
href={itemHref}
title={itemTitle}>
title={itemTitle}
onBeforePress={onBeforePress}>
<View pointerEvents="none">
<PostMeta
author={quote.author}
Expand Down

0 comments on commit 44039c6

Please sign in to comment.