diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 0d25cc2b..87fbac12 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -163,12 +163,11 @@ const PostMedia = ({ post }: PostProps) => { }; const PostMessage = ({ post }: PostProps) => { - const { cid, deleted, edit, original, parentCid, postCid, reason, removed, spoiler, state, subplebbitAddress } = post || {}; + const { cid, content, deleted, edit, original, parentCid, postCid, reason, removed, spoiler, state, subplebbitAddress } = post || {}; const { t } = useTranslation(); const params = useParams(); const location = useLocation(); const isInPostView = isPostPageView(location.pathname, params); - const [content, setContent] = useState(post?.content); const [showOriginal, setShowOriginal] = useState(false); const displayContent = content && !isInPostView && content.length > 1000 ? content?.slice(0, 1000) + '(...)' : content; @@ -193,19 +192,14 @@ const PostMessage = ({ post }: PostProps) => { {t('user_deleted_this_post')} ) : ( <> - + {!showOriginal && } {edit && original?.content !== post?.content && ( + {showOriginal && }
(Edited at {getFormattedDate(edit?.timestamp)},{' '} - { - setContent(showOriginal ? post?.content : original?.content); - setShowOriginal(!showOriginal); - }} - > - show {showOriginal ? 'edited' : 'original'} + setShowOriginal(!showOriginal)}> + {showOriginal ? 'hide original' : 'show original'} ) diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index a79868e0..e29da398 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -119,8 +119,7 @@ const ReplyBacklinks = ({ post }: PostProps) => { const PostMessageMobile = ({ post }: PostProps) => { const { t } = useTranslation(); - const { cid, deleted, edit, original, parentCid, postCid, reason, removed, spoiler, state, subplebbitAddress } = post || {}; - const [content, setContent] = useState(post?.content); + const { cid, content, deleted, edit, original, parentCid, postCid, reason, removed, spoiler, state, subplebbitAddress } = post || {}; const [showOriginal, setShowOriginal] = useState(false); const params = useParams(); @@ -150,19 +149,14 @@ const PostMessageMobile = ({ post }: PostProps) => { {t('user_deleted_this_post')} ) : ( <> - + {!showOriginal && } {edit && original?.content !== post?.content && ( + {showOriginal && }
(Edited at {getFormattedDate(edit?.timestamp)},{' '} - { - setContent(showOriginal ? post?.content : original?.content); - setShowOriginal(!showOriginal); - }} - > - show {showOriginal ? 'edited' : 'original'} + setShowOriginal(!showOriginal)}> + {showOriginal ? 'hide original' : 'show original'} )