Skip to content

Commit

Permalink
fix(post): fix undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
plebeius-eth committed Dec 18, 2023
1 parent a022eb0 commit 84e836a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/post/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const Post = ({ post = {}, index }: PostProps) => {
const stateString = useStateString(post);
const loadingString = stateString && <span className={styles.stateString}>{stateString !== 'Failed' ? <LoadingEllipsis string={stateString} /> : ''}</span>;

const authorRole = subplebbit?.roles?.[post.author.address]?.role;
const authorRole = subplebbit?.roles?.[post.author?.address]?.role;

const isPost = isPostView(location.pathname, params);
const isPending = isPendingView(location.pathname, params);
Expand Down Expand Up @@ -167,7 +167,7 @@ const Post = ({ post = {}, index }: PostProps) => {
<p className={styles.tagline}>
{t('post_submitted')} {getFormattedTimeAgo(timestamp)} {t('post_by')}{' '}
<PostAuthor
authorAddress={author.address}
authorAddress={author?.address}
authorRole={authorRole}
cid={cid}
displayName={displayName}
Expand Down
4 changes: 2 additions & 2 deletions src/components/reply/reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const Reply = ({ depth = 0, isSingle, isNotification = false, reply = {} }: Repl
reply || {};
const subplebbit = useSubplebbit({ subplebbitAddress });

const authorRole = subplebbit?.roles?.[reply.author.address]?.role;
const authorRole = subplebbit?.roles?.[reply.author?.address]?.role;
const { shortAuthorAddress } = useAuthorAddress({ comment: reply });
const replies = useReplies(reply);
const [expanded, setExpanded] = useState(false);
Expand Down Expand Up @@ -187,7 +187,7 @@ const Reply = ({ depth = 0, isSingle, isNotification = false, reply = {} }: Repl
<span className={styles.expand} onClick={() => setCollapsed(!collapsed)}>
[{collapsed ? '+' : '–'}]
</span>
<ReplyAuthor address={author.address} authorRole={authorRole} cid={cid} displayName={author.displayName} shortAuthorAddress={shortAuthorAddress} />
<ReplyAuthor address={author?.address} authorRole={authorRole} cid={cid} displayName={author.displayName} shortAuthorAddress={shortAuthorAddress} />
<span className={styles.score}>{scoreString}</span> <span className={styles.time}>{getFormattedTimeAgo(timestamp)}</span>
{collapsed && <span className={styles.children}> ({childrenString})</span>}
{stateLabel}
Expand Down

0 comments on commit 84e836a

Please sign in to comment.