diff options
author | Hailey <me@haileyok.com> | 2024-04-26 22:31:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-27 06:31:07 +0100 |
commit | 7eb1444f2c82cd25a77445b82178b7299e8452c7 (patch) | |
tree | c160dcafad17ec148f3d0e9b5b03cbf326255821 /src/view/com/posts/FeedItem.tsx | |
parent | ce85375c856549371e1e561e21bb5932baca8ea6 (diff) | |
download | voidsky-7eb1444f2c82cd25a77445b82178b7299e8452c7.tar.zst |
remove precacheThreadPostProfiles (#3729)
* remove `precacheThreadPostProfiles` * add `displayName` to `PreviewableUserAvatar` * memo * use `precacheProfile` * pass `profile` directly to `PreviewableUserAvatar` * update the `UserAvatar`'s props * remove feed cache * one more spot * rm unused queryClient * Don't call fn unnecessarily * Preload for display name too * try notification item * add to feeditem * and finally, precache for post threads * timestamp * Fix * onBeforePress --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/view/com/posts/FeedItem.tsx')
-rw-r--r-- | src/view/com/posts/FeedItem.tsx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 7694b5024..605dffde9 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -13,6 +13,7 @@ import { } from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useQueryClient} from '@tanstack/react-query' import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow' import {useComposerControls} from '#/state/shell/composer' @@ -24,6 +25,7 @@ import {sanitizeDisplayName} from 'lib/strings/display-names' import {sanitizeHandle} from 'lib/strings/handles' import {countLines} from 'lib/strings/helpers' import {s} from 'lib/styles' +import {precacheProfile} from 'state/queries/profile' import {atoms as a} from '#/alf' import {ContentHider} from '#/components/moderation/ContentHider' import {ProfileHoverCard} from '#/components/ProfileHoverCard' @@ -106,6 +108,7 @@ let FeedItemInner = ({ isThreadLastChild?: boolean isThreadParent?: boolean }): React.ReactNode => { + const queryClient = useQueryClient() const {openComposer} = useComposerControls() const pal = usePalette('default') const {_} = useLingui() @@ -135,6 +138,10 @@ let FeedItemInner = ({ }) }, [post, record, openComposer, moderation]) + const onBeforePress = React.useCallback(() => { + precacheProfile(queryClient, post.author) + }, [queryClient, post.author]) + const outerStyles = [ styles.outer, { @@ -153,7 +160,8 @@ let FeedItemInner = ({ style={outerStyles} href={href} noFeedback - accessible={false}> + accessible={false} + onBeforePress={onBeforePress}> <View style={{flexDirection: 'row', gap: 10, paddingLeft: 8}}> <View style={{width: 52}}> {isThreadChild && ( @@ -240,9 +248,7 @@ let FeedItemInner = ({ <View style={styles.layoutAvi}> <PreviewableUserAvatar size={52} - did={post.author.did} - handle={post.author.handle} - avatar={post.author.avatar} + profile={post.author} moderation={moderation.ui('avatar')} type={post.author.associated?.labeler ? 'labeler' : 'user'} /> |