mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(post page): add view specific buttons
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link, useLocation, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Comment } from '@plebbit/plebbit-react-hooks';
|
||||
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
||||
import { getCommentMediaInfoMemoized, getHasThumbnail } from '../../lib/utils/media-utils';
|
||||
import { getFormattedDate } from '../../lib/utils/time-utils';
|
||||
import { isPostPageView } from '../../lib/utils/view-utils';
|
||||
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
|
||||
import useReplies from '../../hooks/use-replies';
|
||||
import styles from './post.module.css';
|
||||
@@ -280,6 +281,7 @@ const ReplyMobile = ({ reply }: Comment) => {
|
||||
};
|
||||
|
||||
const PostMobile = ({ post, showAllReplies }: { post: Comment; showAllReplies: boolean }) => {
|
||||
const { t } = useTranslation();
|
||||
const { author, cid, content, link, linkHeight, linkWidth, pinned, replyCount, shortCid, subplebbitAddress, timestamp, title } = post || {};
|
||||
const { address, displayName, shortAddress } = author || {};
|
||||
const linkCount = useCountLinksInReplies(post);
|
||||
@@ -292,6 +294,10 @@ const PostMobile = ({ post, showAllReplies }: { post: Comment; showAllReplies: b
|
||||
|
||||
const replies = useReplies(post);
|
||||
|
||||
const location = useLocation();
|
||||
const params = useParams();
|
||||
const isInPostPage = isPostPageView(location.pathname, params);
|
||||
|
||||
return (
|
||||
<div className={styles.postMobile}>
|
||||
<div className={styles.hrWrapper}>
|
||||
@@ -342,15 +348,17 @@ const PostMobile = ({ post, showAllReplies }: { post: Comment; showAllReplies: b
|
||||
</blockquote>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.postLink}>
|
||||
<span className={styles.info}>
|
||||
{replyCount} Replies
|
||||
{linkCount > 0 && ` / ${linkCount} Links`}
|
||||
</span>
|
||||
<Link to={`/p/${subplebbitAddress}/c/${cid}`} className='button'>
|
||||
View Thread
|
||||
</Link>
|
||||
</div>
|
||||
{!isInPostPage && (
|
||||
<div className={styles.postLink}>
|
||||
<span className={styles.info}>
|
||||
{replyCount} Replies
|
||||
{linkCount > 0 && ` / ${linkCount} Links`}
|
||||
</span>
|
||||
<Link to={`/p/${subplebbitAddress}/c/${cid}`} className='button'>
|
||||
{t('view_thread')}
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{!pinned &&
|
||||
replies?.slice(0, showAllReplies ? replies.length : 5).map((reply, index) => (
|
||||
|
||||
Reference in New Issue
Block a user