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/posts/FeedItem.tsx | 115 ++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 57 deletions(-) (limited to 'src/view/com/posts/FeedItem.tsx') diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index f7f702c3c..24c8f14f5 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -10,7 +10,6 @@ import {FeedItemModel} from '../../../state/models/feed-view' import {Link} from '../util/Link' import {Text} from '../util/Text' import {UserInfoText} from '../util/UserInfoText' -import {Post} from '../post/Post' import {PostMeta} from '../util/PostMeta' import {PostCtrls} from '../util/PostCtrls' import {PostEmbeds} from '../util/PostEmbeds' @@ -20,22 +19,22 @@ import {UserAvatar} from '../util/UserAvatar' import {s, colors} from '../../lib/styles' import {useStores} from '../../../state' -const TOP_REPLY_LINE_LENGTH = 8 - export const FeedItem = observer(function FeedItem({ item, + showReplyLine, }: { item: FeedItemModel + showReplyLine?: boolean }) { const store = useStores() const [deleted, setDeleted] = useState(false) - const record = item.record as unknown as PostType.Record + const record = item.post.record as unknown as PostType.Record 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 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 replyAuthorDid = useMemo(() => { if (!record.reply) return '' const urip = new AtUri(record.reply.parent?.uri || record.reply.root.uri) @@ -50,13 +49,13 @@ export const FeedItem = observer(function FeedItem({ 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, }, }, }) @@ -92,66 +91,68 @@ export const FeedItem = observer(function FeedItem({ return } - const isChild = - item._isThreadChild || - (!item.repostedBy && !item.trendedBy && item.additionalParentPost?.thread) + const isChild = item._isThreadChild || (!item.reason && item.reply) + const isSmallTop = isChild && item._isThreadChild + const isNoTop = isChild && !item._isThreadChild const outerStyles = [ styles.outer, - isChild - ? item._isThreadChild - ? styles.outerSmallTop - : styles.outerNoTop - : undefined, + isSmallTop ? styles.outerSmallTop : undefined, + isNoTop ? styles.outerNoTop : undefined, item._isThreadParent ? styles.outerNoBottom : undefined, ] return ( <> - {isChild && item.additionalParentPost?.thread ? ( - + {isChild && !item._isThreadChild && item.replyParent ? ( + + + ) : undefined} - {isChild && } - {item._isThreadParent && } - {item.repostedBy && ( + {item._isThreadChild && } + {(showReplyLine || item._isThreadParent) && ( + + )} + {item.reasonRepost && ( + href={`/profile/${item.reasonRepost.by.handle}`} + title={ + item.reasonRepost.by.displayName || item.reasonRepost.by.handle + }> Reposted by{' '} - {item.repostedBy.displayName || item.repostedBy.handle} + {item.reasonRepost.by.displayName || item.reasonRepost.by.handle} )} - {item.trendedBy && ( + {item.reasonTrend && ( + href={`/profile/${item.reasonTrend.by.handle}`} + title={ + item.reasonTrend.by.displayName || item.reasonTrend.by.handle + }> Trending with{' '} - {item.trendedBy.displayName || item.trendedBy.handle} + {item.reasonTrend.by.displayName || item.reasonTrend.by.handle} )} - + @@ -160,10 +161,10 @@ export const FeedItem = observer(function FeedItem({ 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} /> @@ -195,13 +196,13 @@ export const FeedItem = observer(function FeedItem({ ) : ( )} - +