diff --git a/src/components/comment-content/comment-content.tsx b/src/components/comment-content/comment-content.tsx index c78d27cb..8cde1a47 100644 --- a/src/components/comment-content/comment-content.tsx +++ b/src/components/comment-content/comment-content.tsx @@ -114,13 +114,16 @@ const CommentContent = ({ comment: post }: { comment: Comment }) => { const shouldShowReplyingToReply = isReplyingToReply && (parentCid ? !contentNumbers.has(cidToNumber[parentCid] ?? -1) : true); const stateString = useStateString(post); + const hasFailedState = state === 'failed'; - const loadingString =
{stateString !== 'Failed' ? : stateString}
; + const loadingString = ( +
{!hasFailedState ? : stateString || capitalize(t('failed'))}
+ ); return (
{isReply && - state !== 'failed' && + !hasFailedState && !(deleted || removed) && (filteredQuotedCids.length > 0 ? filteredQuotedCids.map((cid: string) => ) @@ -206,7 +209,7 @@ const CommentContent = ({ comment: post }: { comment: Comment }) => { /> )} - {!cid && state === 'pending' && stateString !== 'Failed' && ( + {!cid && !hasFailedState && ( <>

diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 3791513e..cc4dd2c0 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -86,7 +86,7 @@ const PostInfo = ({ const { address, shortAddress } = author || {}; const displayName = author?.displayName?.trim(); const authorRole = roles?.[address]?.role?.replace('moderator', 'mod'); - const stateString = useStateString(post); + const hasFailedState = state === 'failed'; const isReply = parentCid; const { showOmittedReplies } = useShowOmittedReplies(); const { imageUrl: avatarImageUrl } = useAuthorAvatar({ author }); @@ -335,9 +335,7 @@ const PostInfo = ({ ) : ( <> No. - - {state === 'failed' || stateString === 'Failed' ? capitalize(t('failed')) : state === 'pending' ? capitalize(t('pending')) : ''} - + {hasFailedState ? capitalize(t('failed')) : capitalize(t('pending'))} )} {pinned && ( @@ -702,6 +700,7 @@ const PostDesktop = ({ const { showOmittedReplies, setShowOmittedReplies } = useShowOmittedReplies(); const stateString = useStateString(post) || t('downloading_board'); + const hasFailedState = state === 'failed'; const commentMediaInfo = useCommentMediaInfo(link, thumbnailUrl, linkWidth, linkHeight); const hasThumbnail = getHasThumbnail(commentMediaInfo, link); @@ -910,13 +909,13 @@ const PostDesktop = ({ ))} - {!isInPendingPostView && stateString && stateString !== 'Failed' && state !== 'succeeded' && isInPostPageView && !(!showReplies && !showAllReplies) ? ( + {!isInPendingPostView && stateString && !hasFailedState && state !== 'succeeded' && isInPostPageView && !(!showReplies && !showAllReplies) ? (

) : ( - state === 'failed' && {t('failed')} + hasFailedState && {t('failed')} )} ); diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index a11ee015..7a58af1e 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -168,7 +168,7 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber }: Pos const alertThresholdSeconds = getAlertThresholdSeconds(); const isOverThreshold = isAwaitingApproval && timeWaiting > alertThresholdSeconds; - const stateString = useStateString(post); + const hasFailedState = state === 'failed'; const postMenuProps = useMemo(() => selectPostMenuProps(post), [post]); const pseudonymityMode = useSubplebbitField(subplebbitAddress, (sub) => sub?.features?.pseudonymityMode); @@ -326,9 +326,7 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber }: Pos ) : ( <> No. - - {state === 'failed' || stateString === 'Failed' ? capitalize(t('failed')) : state === 'pending' ? capitalize(t('pending')) : ''} - + {hasFailedState ? capitalize(t('failed')) : capitalize(t('pending'))} )} {shouldShowPendingApprovalButtons && ( @@ -513,6 +511,7 @@ const PostMobile = ({ const { hidden, unhide } = useHide({ cid }); const stateString = useStateString(post) || t('loading_post'); + const hasFailedState = state === 'failed'; // Filter out deleted replies with no children for both virtuoso and non-virtuoso rendering const filteredReplies = useMemo(() => (replies || []).filter((reply) => !(reply.deleted && (reply.replyCount === 0 || !reply.replyCount))), [replies]); @@ -669,12 +668,12 @@ const PostMobile = ({ ))} - {!isInPendingPostView && stateString && stateString !== 'Failed' && state !== 'succeeded' && isInPostPageView && !(!showReplies && !showAllReplies) ? ( + {!isInPendingPostView && stateString && !hasFailedState && state !== 'succeeded' && isInPostPageView && !(!showReplies && !showAllReplies) ? (
) : ( - state === 'failed' && {t('failed')} + hasFailedState && {t('failed')} )} )}