();
const matches = content.matchAll(/(?/\w])>>(\d+)(?![\d/])/g);
return new Set([...matches].map((m) => parseInt(m[1], 10)));
}, [content]);
const relevantQuotedCids = useMemo(() => {
const cids = quotedCids ? [...quotedCids] : [];
if (parentCid) {
cids.push(parentCid);
}
return cids;
}, [quotedCids, parentCid]);
const cidToNumber = useScopedCidToNumber(relevantQuotedCids);
const filteredQuotedCids = useMemo(() => {
if (!quotedCids?.length) return [];
return quotedCids.filter((cid: string) => {
const num = cidToNumber[cid];
return num === undefined || !contentNumbers.has(num);
});
}, [quotedCids, cidToNumber, contentNumbers]);
const shouldShowReplyingToReply = isReplyingToReply && (parentCid ? !contentNumbers.has(cidToNumber[parentCid] ?? -1) : true);
const stateString = useStateString(post);
const loadingString = {stateString !== 'Failed' ? : stateString}
;
return (
{isReply &&
state !== 'failed' &&
!(deleted || removed) &&
(filteredQuotedCids.length > 0
? filteredQuotedCids.map((cid: string) => )
: shouldShowReplyingToReply && )}
{removed ? (
reason ? (
<>
({t('this_post_was_removed')})
{`${capitalize(t('reason'))}: "${reason}"`}
>
) : (
{capitalize(t('this_post_was_removed'))}.
)
) : deleted ? (
reason ? (
<>
{t('user_deleted_this_post')}{' '}
{`${capitalize(t('reason'))}: "${reason}"`}
>
) : (
{t('user_deleted_this_post')}
)
) : (
<>
{!showOriginal && }
{pendingApproval && (
<>
({t('pending_mod_approval')})
>
)}
{((!isInPostView && content?.length > 1000 && !showFullComment) || (isInPostView && content?.length > 2000 && !showFullComment)) && (
setShowFullComment(true)} /> }} />
)}
{edit && original?.content !== content && (
{showOriginal && }
} />,
}}
/>{' '}
{reason && <>{t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })} >}
{showOriginal ? (
setShowOriginal(!showOriginal)} /> }}
/>
) : (
setShowOriginal(!showOriginal)} /> }}
/>
)}
)}
>
)}
{banned && (
)}
{!cid && state === 'pending' && stateString !== 'Failed' && (
<>
{loadingString}
>
)}
);
};
export default CommentContent;