From ce24710a1f854ccfd4beaacd1acda5a2d0f05252 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 8 Apr 2024 12:37:44 +0200 Subject: [PATCH] Update post.tsx --- src/components/post/post.tsx | 254 +++++++++++++++++------------------ 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index d16e8a74..8465a43d 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -11,96 +11,6 @@ import styles from './post.module.css'; import Markdown from '../markdown'; import Media from '../media'; -const ReplyDesktop = ({ reply }: any) => { - const { t } = useTranslation(); - const { author, content, link, linkHeight, linkWidth, parentCid, pinned, postCid, shortCid, subplebbitAddress, timestamp } = reply || {}; - const { displayName, shortAddress } = author || {}; - - const commentMediaInfo = getCommentMediaInfoMemoized(reply); - const hasThumbnail = getHasThumbnail(commentMediaInfo, link); - const [showThumbnail, setShowThumbnail] = useState(true); - - const isReplyingToReply = postCid !== parentCid; - - return ( -
-
{'>>'}
-
-
- - - - - {displayName || 'Anonymous'} - (u/{shortAddress}) - - {getFormattedDate(timestamp)} - - - - c/ - - - {shortCid} - - - {pinned && ( - - - - )} - - -
- {link && ( -
-
- {t('link')}:{' '} - - {link.length > 30 ? link?.slice(0, 30) + '...' : link} - - {!showThumbnail && (commentMediaInfo?.type === 'iframe' || commentMediaInfo?.type === 'video') && ( - - {' '} - [ - setShowThumbnail(true)}> - {t('close')} - - ] - - )} -
- {hasThumbnail && ( - - )} -
- )} - {content && ( -
- {isReplyingToReply && ( - <> - - {`c/${Plebbit.getShortCid(parentCid)}`} - -
- - )} - -
- )} -
-
- ); -}; - const PostDesktop = ({ post, showAllReplies }: PostProps) => { const { t } = useTranslation(); const { author, cid, content, link, linkHeight, linkWidth, locked, pinned, postCid, replyCount, shortCid, subplebbitAddress, timestamp, title } = post || {}; @@ -235,7 +145,8 @@ const PostDesktop = ({ post, showAllReplies }: PostProps) => { ); }; -const ReplyMobile = ({ reply }: any) => { +const ReplyDesktop = ({ reply }: any) => { + const { t } = useTranslation(); const { author, content, link, linkHeight, linkWidth, parentCid, pinned, postCid, shortCid, subplebbitAddress, timestamp } = reply || {}; const { displayName, shortAddress } = author || {}; @@ -246,45 +157,79 @@ const ReplyMobile = ({ reply }: any) => { const isReplyingToReply = postCid !== parentCid; return ( -
+
+
{'>>'}
-
-
- ... - - {displayName || 'Anonymous'} - (u/{shortAddress}) +
+ + + + + {displayName || 'Anonymous'} + (u/{shortAddress}) + + {getFormattedDate(timestamp)} + + + + c/ + + + {shortCid} + - - {getFormattedDate(timestamp)} c/ - {shortCid} - -
- {hasThumbnail && ( - - )} - {content && ( -
- {isReplyingToReply && ( - <> - - {`c/${Plebbit.getShortCid(parentCid)}`} - -
- - )} - -
- )} + {pinned && ( + + + + )} +
+
+ {link && ( +
+
+ {t('link')}:{' '} + + {link.length > 30 ? link?.slice(0, 30) + '...' : link} + + {!showThumbnail && (commentMediaInfo?.type === 'iframe' || commentMediaInfo?.type === 'video') && ( + + {' '} + [ + setShowThumbnail(true)}> + {t('close')} + + ] + + )} +
+ {hasThumbnail && ( + + )} +
+ )} + {content && ( +
+ {isReplyingToReply && ( + <> + + {`c/${Plebbit.getShortCid(parentCid)}`} + +
+ + )} + +
+ )}
); @@ -386,6 +331,61 @@ const PostMobile = ({ post, showAllReplies }: PostProps) => { ); }; +const ReplyMobile = ({ reply }: any) => { + const { author, content, link, linkHeight, linkWidth, parentCid, pinned, postCid, shortCid, subplebbitAddress, timestamp } = reply || {}; + const { displayName, shortAddress } = author || {}; + + const commentMediaInfo = getCommentMediaInfoMemoized(reply); + const hasThumbnail = getHasThumbnail(commentMediaInfo, link); + const [showThumbnail, setShowThumbnail] = useState(true); + + const isReplyingToReply = postCid !== parentCid; + + return ( +
+
+
+
+ ... + + {displayName || 'Anonymous'} + (u/{shortAddress}) + + + {getFormattedDate(timestamp)} c/ + {shortCid} + +
+ {hasThumbnail && ( + + )} + {content && ( +
+ {isReplyingToReply && ( + <> + + {`c/${Plebbit.getShortCid(parentCid)}`} + +
+ + )} + +
+ )} +
+
+
+ ); +}; + interface PostProps { index?: number; post: any;