diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx
index fc444f59..acaca07a 100644
--- a/src/components/post/post.tsx
+++ b/src/components/post/post.tsx
@@ -26,16 +26,17 @@ interface PostProps {
reply?: any;
roles?: Role[];
showAllReplies?: boolean;
- stateString?: string;
openReplyModal?: (cid: string) => void;
}
-const PostInfoDesktop = ({ isInPostPage, openReplyModal, post, roles, stateString }: PostProps) => {
+const PostInfoDesktop = ({ isInPostPage, openReplyModal, post, roles }: PostProps) => {
const { t } = useTranslation();
const { author, cid, locked, pinned, postCid, shortCid, state, subplebbitAddress, timestamp, title } = post || {};
const { address, displayName, shortAddress } = author || {};
const { isDescription, isRules } = post || {}; // custom properties, not from api
+ const stateString = useStateString(post);
+
const isReply = post?.parentCid;
const shortDisplayName = displayName?.trim().length > 20 ? displayName?.trim().slice(0, 20).trim() + '...' : displayName?.trim();
@@ -185,16 +186,52 @@ const PostMediaDesktop = ({ post }: PostProps) => {
);
};
-const PostDesktop = ({ isInPostPage, isPendingPostPage, openReplyModal, post, roles, showAllReplies, stateString }: PostProps) => {
- const { cid, content, pinned, replyCount, state, subplebbitAddress } = post || {};
- const { isDescription, isRules } = post || {}; // custom properties, not from api
-
+const PostMessageDesktop = ({ isInPostPage, post }: PostProps) => {
+ const { cid, content, parentCid, postCid, state, subplebbitAddress } = post || {};
const displayContent = content && !isInPostPage && content.length > 1000 ? content?.slice(0, 1000) + '(...)' : content;
+ const isReply = parentCid;
+ const isReplyingToReply = postCid !== parentCid;
+
+ const stateString = useStateString(post);
+
const loadingString = stateString && (
{stateString !== 'Failed' ? : stateString}
);
+ return (
+ content && (
+
+ {isReply && isReplyingToReply && (
+ <>
+
+ {`c/${parentCid && Plebbit.getShortCid(parentCid)}`}
+
+
+ >
+ )}
+
+ {!isReply && content.length > 1000 && !isInPostPage && (
+
+
+ }} />
+
+ )}
+ {!cid && state === 'pending' && stateString !== 'Failed' && (
+ <>
+
+ {loadingString}
+ >
+ )}
+
+ )
+ );
+};
+
+const PostDesktop = ({ isInPostPage, isPendingPostPage, openReplyModal, post, roles, showAllReplies }: PostProps) => {
+ const { cid, content, pinned, replyCount, subplebbitAddress } = post || {};
+ const { isDescription, isRules } = post || {}; // custom properties, not from api
+
const replies = useReplies(post);
const visiblelinksCount = useCountLinksInReplies(post, 5);
const totallinksCount = useCountLinksInReplies(post);
@@ -212,32 +249,9 @@ const PostDesktop = ({ isInPostPage, isPendingPostPage, openReplyModal, post, ro
)}
-
+
{!content && }
- {content && (
-
-
- {content.length > 1000 && !isInPostPage && (
-
-
- }} />
-
- )}
- {!cid && state === 'pending' && stateString !== 'Failed' && (
- <>
-
- {loadingString}
- >
- )}
-
- )}
+
{!isDescription && !isRules && !isPendingPostPage && (replies.length > 5 || (pinned && replies.length > 0)) && !isInPostPage && (
@@ -270,53 +284,19 @@ const PostDesktop = ({ isInPostPage, isPendingPostPage, openReplyModal, post, ro
};
const ReplyDesktop = ({ isInPostPage, isPendingPostPage, reply, roles, openReplyModal }: PostProps) => {
- const { cid, content, parentCid, postCid, state, subplebbitAddress } = reply || {};
-
- const isReplyingToReply = postCid !== parentCid;
-
- const stateString = useStateString(reply);
- const loadingString = stateString && (
- {stateString !== 'Failed' ? : stateString}
- );
-
return (
{'>>'}
-
+
- {content && (
-
- {isReplyingToReply && (
- <>
-
- {`c/${parentCid && Plebbit.getShortCid(parentCid)}`}
-
-
- >
- )}
-
- {!cid && state === 'pending' && stateString !== 'Failed' && (
- <>
-
- {loadingString}
- >
- )}
-
- )}
+
);
};
-const PostMobile = ({ isInPostPage, isPendingPostPage, openReplyModal, post, roles, showAllReplies, stateString }: PostProps) => {
+const PostMobile = ({ isInPostPage, isPendingPostPage, openReplyModal, post, roles, showAllReplies }: PostProps) => {
const { t } = useTranslation();
const { author, cid, content, link, linkHeight, linkWidth, locked, pinned, replyCount, shortCid, state, subplebbitAddress, timestamp, title } = post || {};
const { address, displayName, shortAddress } = author || {};
@@ -339,6 +319,8 @@ const PostMobile = ({ isInPostPage, isPendingPostPage, openReplyModal, post, rol
const account = useAccount();
const accountShortAddress = account?.author?.shortAddress;
+ const stateString = useStateString(post);
+
const loadingString = stateString && (
{stateString !== 'Failed' ? : stateString}
);
@@ -452,7 +434,7 @@ const PostMobile = ({ isInPostPage, isPendingPostPage, openReplyModal, post, rol
);
};
-const ReplyMobile = ({ openReplyModal, reply, roles, stateString }: PostProps) => {
+const ReplyMobile = ({ openReplyModal, reply, roles }: PostProps) => {
const { t } = useTranslation();
const { author, content, cid, link, linkHeight, linkWidth, parentCid, pinned, postCid, shortCid, state, subplebbitAddress, timestamp } = reply || {};
const { address, displayName, shortAddress } = author || {};
@@ -469,6 +451,8 @@ const ReplyMobile = ({ openReplyModal, reply, roles, stateString }: PostProps) =
const account = useAccount();
const accountShortAddress = account?.author?.shortAddress;
+ const stateString = useStateString(reply);
+
const loadingString = stateString && (
{stateString !== 'Failed' ? : stateString}
);
@@ -551,8 +535,6 @@ const Post = ({ post, showAllReplies = false, openReplyModal }: PostProps) => {
const isInPostPage = isPostPageView(location.pathname, params);
const isPendingPostPage = isPendingPostView(location.pathname, params);
- const stateString = useStateString(post);
-
return (
@@ -563,7 +545,6 @@ const Post = ({ post, showAllReplies = false, openReplyModal }: PostProps) => {
post={post}
roles={subplebbit?.roles}
showAllReplies={showAllReplies}
- stateString={stateString}
openReplyModal={openReplyModal}
/>
) : (
@@ -573,7 +554,6 @@ const Post = ({ post, showAllReplies = false, openReplyModal }: PostProps) => {
post={post}
roles={subplebbit?.roles}
showAllReplies={showAllReplies}
- stateString={stateString}
openReplyModal={openReplyModal}
/>
)}