Skip to content

Commit

Permalink
fix(reply): don't show long subplebbit addresses, shorten them instead
Browse files Browse the repository at this point in the history
  • Loading branch information
plebeius-eth committed Dec 25, 2023
1 parent 9b9d0cb commit f1c8249
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/reply/reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import useDownvote from '../../hooks/use-downvote';
import useStateString from '../../hooks/use-state-string';
import useUpvote from '../../hooks/use-upvote';
import { isInboxView } from '../../lib/utils/view-utils';
import { getShortAddress } from '@plebbit/plebbit-js';

interface ReplyAuthorProps {
address: string;
Expand Down Expand Up @@ -134,8 +135,8 @@ const ParentLink = ({ postCid }: ParentLinkProps) => {
const InboxParentLink = ({ commentCid }: ParentLinkProps) => {
const inboxComment = useComment({ commentCid });
const { postCid, parentCid } = inboxComment || {};
const parentComment = useComment({ commentCid: inboxComment?.postCid });
const { cid, content, title, subplebbitAddress } = parentComment || {};
const parent = useComment({ commentCid: inboxComment?.postCid });
const { cid, content, title, subplebbitAddress } = parent || {};
// const { t } = useTranslation();
const postTitle = (title?.length > 300 ? title?.slice(0, 300) + '...' : title) || (content?.length > 300 ? content?.slice(0, 300) + '...' : content);

Expand All @@ -155,6 +156,7 @@ const InboxParentLink = ({ commentCid }: ParentLinkProps) => {
const InboxParentInfo = ({ commentCid }: ParentLinkProps) => {
const parent = useComment({ commentCid });
const { author, cid, subplebbitAddress, timestamp } = parent || {};
const shortSubplebbitAddress = subplebbitAddress ? (subplebbitAddress.includes('.') ? subplebbitAddress : getShortAddress(subplebbitAddress)) : '';

return (
<>
Expand All @@ -165,7 +167,7 @@ const InboxParentInfo = ({ commentCid }: ParentLinkProps) => {
</Link>
via{' '}
<Link to={`/p/${subplebbitAddress}`} className={styles.inboxParentSubplebbit}>
p/{subplebbitAddress}{' '}
p/{shortSubplebbitAddress}{' '}
</Link>
sent {getFormattedTimeAgo(timestamp)}
</div>
Expand Down

0 comments on commit f1c8249

Please sign in to comment.