From 44039c68d678e99f9dc712f1a6dae87aed970ca3 Mon Sep 17 00:00:00 2001
From: Hailey <me@haileyok.com>
Date: Fri, 12 Apr 2024 12:53:48 -0700
Subject: Store QP authors in the DID cache (#3509)

* store qp author in did cache

* organize

* this seems nicer

* move outside of jsx
---
 src/view/com/util/post-embeds/QuoteEmbed.tsx | 43 +++++++++++++++++-----------
 1 file changed, 26 insertions(+), 17 deletions(-)

(limited to 'src/view/com/util/post-embeds/QuoteEmbed.tsx')

diff --git a/src/view/com/util/post-embeds/QuoteEmbed.tsx b/src/view/com/util/post-embeds/QuoteEmbed.tsx
index 2b1c3e617..b5f57825b 100644
--- a/src/view/com/util/post-embeds/QuoteEmbed.tsx
+++ b/src/view/com/util/post-embeds/QuoteEmbed.tsx
@@ -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,
@@ -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)
@@ -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}
-- 
cgit 1.4.1

