fix(pending posts): clean up failed post display

This commit is contained in:
Tommaso Casaburi
2026-04-30 17:39:06 +07:00
parent e6096fd989
commit 5c74a1e495
6 changed files with 45 additions and 16 deletions
@@ -397,7 +397,8 @@ describe('CommentContent', () => {
postCid: 'post-2',
state: 'failed',
});
expect(container.textContent).toContain('Failed to publish');
expect(container.textContent).not.toContain('Failed to publish');
expect(container.textContent).toContain('still pending');
expect(container.querySelector('[data-testid="loading-ellipsis"]')).toBeNull();
testState.stateString = 'Publishing';
@@ -131,6 +131,7 @@ const CommentContent = ({ comment: post, prependContent }: { comment: Comment; p
const stateString = useStateString(resolvedPost);
const hasFailedState = state === 'failed';
const failedError = getFailedCommentError(resolvedPost);
const shouldShowUnpublishedStateDetails = !cid && (!hasFailedState || Boolean(failedError));
const loadingString = (
<div className={styles.stateString}>
@@ -298,7 +299,7 @@ const CommentContent = ({ comment: post, prependContent }: { comment: Comment; p
</Tooltip>
</span>
)}
{!cid && (
{shouldShowUnpublishedStateDetails && (
<>
<br />
<br />
+7 -4
View File
@@ -384,7 +384,7 @@ const PostInfo = ({
) : purged ? (
t('purged')
) : !cid && pseudonymityMode ? (
<span className={styles.pendingCid}>{hasFailedState ? capitalize(t('failed')) : capitalize(t('pending'))}</span>
<span className={styles.pendingCid}>{hasFailedState ? '?' : capitalize(t('pending'))}</span>
) : (
<Tooltip
content={`${numberOfPostsByAuthor === 1 ? t('1_post_by_this_id') : t('x_posts_by_this_id', { number: numberOfPostsByAuthor })}`}
@@ -451,7 +451,7 @@ const PostInfo = ({
) : (
<>
<span>No.</span>
<span className={styles.pendingCid}>{hasFailedState ? capitalize(t('failed')) : capitalize(t('pending'))}</span>
<span className={styles.pendingCid}>{hasFailedState ? '?' : capitalize(t('pending'))}</span>
</>
)}
{pinned && (
@@ -855,6 +855,7 @@ const PostDesktop = ({
const isMultiboardView = isInAllView || isInSubscriptionsView || isInModView;
const directories = useDirectories();
const boardPath = communityAddress ? getBoardPath(communityAddress, directories) : undefined;
const deleteFailedPostRedirectPath = isInPendingPostView ? (boardPath ? `/${boardPath}` : '/') : undefined;
const displayBoardPath =
boardPath && communityAddress
? boardPath !== communityAddress
@@ -957,8 +958,10 @@ const PostDesktop = ({
const stateString = useStateString(resolvedPost) || t('downloading_board');
const hasFailedState = state === 'failed';
const { canDeleteFailedPost, canRetryFailedPost, isDeletingFailedPost, isRetryingFailedPost, onDeleteFailedPost, onRetryFailedPost } =
useDeleteFailedPost(resolvedPost);
const { canDeleteFailedPost, canRetryFailedPost, isDeletingFailedPost, isRetryingFailedPost, onDeleteFailedPost, onRetryFailedPost } = useDeleteFailedPost(
resolvedPost,
deleteFailedPostRedirectPath,
);
const failedPublishNotice = canDeleteFailedPost ? (
<FailedPublishNotice
isDeleting={isDeletingFailedPost}
+7 -4
View File
@@ -311,7 +311,7 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber, posts
) : purged ? (
lowerCase(t('purged'))
) : !cid && pseudonymityMode ? (
<span className={styles.pendingCid}>{hasFailedState ? capitalize(t('failed')) : capitalize(t('pending'))}</span>
<span className={styles.pendingCid}>{hasFailedState ? '?' : capitalize(t('pending'))}</span>
) : (
<Tooltip
content={`${numberOfPostsByAuthor === 1 ? t('1_post_by_this_id') : t('x_posts_by_this_id', { number: numberOfPostsByAuthor })}`}
@@ -410,7 +410,7 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber, posts
) : (
<>
<span>No.</span>
<span className={styles.pendingCid}>{hasFailedState ? capitalize(t('failed')) : capitalize(t('pending'))}</span>
<span className={styles.pendingCid}>{hasFailedState ? '?' : capitalize(t('pending'))}</span>
</>
)}
{shouldShowPendingApprovalButtons && (
@@ -595,6 +595,7 @@ const PostMobile = ({
</button>
) : null;
const linksCount = useCountLinksInReplies(resolvedPost);
const deleteFailedPostRedirectPath = isInPendingPostView ? (boardPath ? `/${boardPath}` : '/') : undefined;
const hasReplyPaginationOverride = !!replyPaginationOverride;
const shouldFetchReplies = showReplies && !isModQueue && !hasReplyPaginationOverride;
const shouldUsePreview = shouldFetchReplies && !showAllReplies;
@@ -668,8 +669,10 @@ const PostMobile = ({
const stateString = useStateString(resolvedPost) || t('loading_post');
const hasFailedState = state === 'failed';
const isReply = !!parentCid;
const { canDeleteFailedPost, canRetryFailedPost, isDeletingFailedPost, isRetryingFailedPost, onDeleteFailedPost, onRetryFailedPost } =
useDeleteFailedPost(resolvedPost);
const { canDeleteFailedPost, canRetryFailedPost, isDeletingFailedPost, isRetryingFailedPost, onDeleteFailedPost, onRetryFailedPost } = useDeleteFailedPost(
resolvedPost,
deleteFailedPostRedirectPath,
);
const failedPublishNotice = canDeleteFailedPost ? (
<FailedPublishNotice
isDeleting={isDeletingFailedPost}