mirror of
https://github.com/plebbit/seedit.git
synced 2026-05-25 00:57:02 -04:00
feat(author): redirect to profile if author is account
This commit is contained in:
@@ -56,13 +56,13 @@ const AuthorSidebar = () => {
|
||||
const { authorComments } = useAuthorComments({ authorAddress, commentCid });
|
||||
const authorOldestCommentTimestamp = authorComments?.[0]?.timestamp || Date.now();
|
||||
const authorSubplebbits = findAuthorSubplebbits(authorAddress, subplebbits.subplebbits);
|
||||
|
||||
|
||||
const estimatedAuthorKarma = estimateAuthorKarma(authorComments);
|
||||
|
||||
const address = isAuthorPage ? params?.authorAddress : isProfilePage ? profileAccount?.author?.shortAddress : '';
|
||||
const karma = isAuthorPage ? estimatedAuthorKarma : isProfilePage ? profileAccount?.karma : '';
|
||||
const { postScore, replyScore } = karma || {};
|
||||
|
||||
|
||||
const oldestCommentTimestamp = isAuthorPage ? authorOldestCommentTimestamp : isProfilePage ? profileOldestAccountTimestamp : Date.now();
|
||||
const displayName = isAuthorPage ? authorAccount?.author?.displayName : isProfilePage ? profileAccount?.author?.displayName : '';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ type ModToolsProps = {
|
||||
cid: string;
|
||||
};
|
||||
|
||||
const ModTools = ({cid}: ModToolsProps) => {
|
||||
const ModTools = ({ cid }: ModToolsProps) => {
|
||||
const { t } = useTranslation();
|
||||
const post = useComment({ commentCid: cid });
|
||||
const [isModToolsOpen, setIsModToolsOpen] = useState(false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useRef } from 'react';
|
||||
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||
import { useAuthorComments } from '@plebbit/plebbit-react-hooks';
|
||||
import { useAccount, useAuthorComments } from '@plebbit/plebbit-react-hooks';
|
||||
import { StateSnapshot, Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
||||
import { isAuthorCommentsView, isAuthorSubmittedView } from '../../lib/utils/view-utils';
|
||||
import styles from './author.module.css';
|
||||
@@ -12,6 +12,7 @@ import Reply from '../../components/reply/';
|
||||
const lastVirtuosoStates: { [key: string]: StateSnapshot } = {};
|
||||
|
||||
const Author = () => {
|
||||
const account = useAccount();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { authorAddress, commentCid, sortType } = useParams();
|
||||
@@ -61,6 +62,13 @@ const Author = () => {
|
||||
}
|
||||
}, [authorAddress, lastCommentCid, commentCid, navigate]);
|
||||
|
||||
// redirect to profile if author is account
|
||||
useEffect(() => {
|
||||
if (authorAddress && account?.author?.address === authorAddress) {
|
||||
navigate(`/profile`, { replace: true });
|
||||
}
|
||||
}, [authorAddress, account, navigate]);
|
||||
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
<div className={styles.sidebar}>
|
||||
|
||||
Reference in New Issue
Block a user