From e7d971410f080f3dd748655eaa0e306bd0031d78 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 20 Dec 2022 22:54:56 -0600 Subject: Update to use new getTimeline, getAuthorFeed, and getPostThread output models --- src/view/com/post-thread/PostThreadItem.tsx | 100 ++++++++++++++-------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'src/view/com/post-thread/PostThreadItem.tsx') diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 70b313ecc..c45de2cb0 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -32,37 +32,37 @@ export const PostThreadItem = observer(function PostThreadItem({ }) { const store = useStores() const [deleted, setDeleted] = useState(false) - const record = item.record as unknown as PostType.Record - const hasEngagement = item.upvoteCount || item.repostCount + const record = item.post.record as unknown as PostType.Record + const hasEngagement = item.post.upvoteCount || item.post.repostCount const itemHref = useMemo(() => { - const urip = new AtUri(item.uri) - return `/profile/${item.author.handle}/post/${urip.rkey}` - }, [item.uri, item.author.handle]) - const itemTitle = `Post by ${item.author.handle}` - const authorHref = `/profile/${item.author.handle}` - const authorTitle = item.author.handle + const urip = new AtUri(item.post.uri) + return `/profile/${item.post.author.handle}/post/${urip.rkey}` + }, [item.post.uri, item.post.author.handle]) + const itemTitle = `Post by ${item.post.author.handle}` + const authorHref = `/profile/${item.post.author.handle}` + const authorTitle = item.post.author.handle const upvotesHref = useMemo(() => { - const urip = new AtUri(item.uri) - return `/profile/${item.author.handle}/post/${urip.rkey}/upvoted-by` - }, [item.uri, item.author.handle]) + const urip = new AtUri(item.post.uri) + return `/profile/${item.post.author.handle}/post/${urip.rkey}/upvoted-by` + }, [item.post.uri, item.post.author.handle]) const upvotesTitle = 'Upvotes on this post' const repostsHref = useMemo(() => { - const urip = new AtUri(item.uri) - return `/profile/${item.author.handle}/post/${urip.rkey}/reposted-by` - }, [item.uri, item.author.handle]) + const urip = new AtUri(item.post.uri) + return `/profile/${item.post.author.handle}/post/${urip.rkey}/reposted-by` + }, [item.post.uri, item.post.author.handle]) const repostsTitle = 'Reposts of this post' const onPressReply = () => { store.shell.openComposer({ replyTo: { - uri: item.uri, - cid: item.cid, - text: item.record.text as string, + uri: item.post.uri, + cid: item.post.cid, + text: record.text as string, author: { - handle: item.author.handle, - displayName: item.author.displayName, - avatar: item.author.avatar, + handle: item.post.author.handle, + displayName: item.post.author.displayName, + avatar: item.post.author.avatar, }, }, onPost: onPostReply, @@ -113,9 +113,9 @@ export const PostThreadItem = observer(function PostThreadItem({ @@ -126,18 +126,18 @@ export const PostThreadItem = observer(function PostThreadItem({ href={authorHref} title={authorTitle}> - {item.author.displayName || item.author.handle} + {item.post.author.displayName || item.post.author.handle} - · {ago(item.indexedAt)} + · {ago(item.post.indexedAt)} - @{item.author.handle} + @{item.post.author.handle} @@ -173,34 +173,34 @@ export const PostThreadItem = observer(function PostThreadItem({ /> ) : undefined} - + {item._isHighlightedPost && hasEngagement ? ( - {item.repostCount ? ( + {item.post.repostCount ? ( - {item.repostCount} + {item.post.repostCount} {' '} - {pluralize(item.repostCount, 'repost')} + {pluralize(item.post.repostCount, 'repost')} ) : ( <> )} - {item.upvoteCount ? ( + {item.post.upvoteCount ? ( - {item.upvoteCount} + {item.post.upvoteCount} {' '} - {pluralize(item.upvoteCount, 'upvote')} + {pluralize(item.post.upvoteCount, 'upvote')} ) : ( @@ -213,8 +213,8 @@ export const PostThreadItem = observer(function PostThreadItem({ - {!item.replyingTo && item.record.reply && ( + {!item.replyingTo && record.reply && ( )} {item.replies?.length !== 0 && } @@ -259,9 +259,9 @@ export const PostThreadItem = observer(function PostThreadItem({ @@ -270,10 +270,10 @@ export const PostThreadItem = observer(function PostThreadItem({ itemHref={itemHref} itemTitle={itemTitle} authorHref={authorHref} - authorHandle={item.author.handle} - authorDisplayName={item.author.displayName} - timestamp={item.indexedAt} - isAuthor={item.author.did === store.me.did} + authorHandle={item.post.author.handle} + authorDisplayName={item.post.author.displayName} + timestamp={item.post.indexedAt} + isAuthor={item.post.author.did === store.me.did} onCopyPostText={onCopyPostText} onDeletePost={onDeletePost} /> @@ -288,13 +288,13 @@ export const PostThreadItem = observer(function PostThreadItem({ ) : ( )} - +