fix undefined

This commit is contained in:
Tom
2023-05-22 13:16:16 +02:00
parent 482c46422c
commit 2d3fcc330a
2 changed files with 24 additions and 24 deletions
+5 -5
View File
@@ -92,7 +92,7 @@ const Board = () => {
useEffect(() => { useEffect(() => {
if (subplebbit.roles !== undefined) { if (subplebbit.roles !== undefined) {
const role = subplebbit.roles[account.author.address]?.role; const role = subplebbit.roles[account?.author.address]?.role;
if (role === 'moderator' || role === 'admin' || role === 'owner') { if (role === 'moderator' || role === 'admin' || role === 'owner') {
setIsModerator(true); setIsModerator(true);
@@ -757,7 +757,7 @@ const Board = () => {
style={{ display: rotatedStates[thread.cid] ? 'block' : 'none' }}> style={{ display: rotatedStates[thread.cid] ? 'block' : 'none' }}>
<ul> <ul>
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li> <li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li>
{thread.author.shortAddress === account.author.shortAddress ? ( {thread.author.shortAddress === account?.author.shortAddress ? (
<> <>
<li onClick={() => handleOptionClick(thread.cid)}>Edit post</li> <li onClick={() => handleOptionClick(thread.cid)}>Edit post</li>
<li onClick={() => handleOptionClick(thread.cid)}>Delete post</li> <li onClick={() => handleOptionClick(thread.cid)}>Delete post</li>
@@ -765,7 +765,7 @@ const Board = () => {
) : null} ) : null}
{isModerator ? ( {isModerator ? (
<> <>
{thread.author.shortAddress === account.author.shortAddress ? ( {thread.author.shortAddress === account?.author.shortAddress ? (
null null
) : ( ) : (
<li onClick={() => { <li onClick={() => {
@@ -955,7 +955,7 @@ const Board = () => {
style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}> style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}>
<ul> <ul>
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li> <li onClick={() => handleOptionClick(reply.cid)}>Hide post</li>
{reply.author.shortAddress === account.author.shortAddress ? ( {reply.author.shortAddress === account?.author.shortAddress ? (
<> <>
<li onClick={() => handleOptionClick(reply.cid)}>Edit post</li> <li onClick={() => handleOptionClick(reply.cid)}>Edit post</li>
<li onClick={() => handleOptionClick(reply.cid)}>Delete post</li> <li onClick={() => handleOptionClick(reply.cid)}>Delete post</li>
@@ -963,7 +963,7 @@ const Board = () => {
) : null} ) : null}
{isModerator ? ( {isModerator ? (
<> <>
{reply.author.shortAddress === account.author.shortAddress ? ( {reply.author.shortAddress === account?.author.shortAddress ? (
null null
) : ( ) : (
<li onClick={() => { <li onClick={() => {
+19 -19
View File
@@ -89,7 +89,7 @@ const Thread = () => {
useEffect(() => { useEffect(() => {
if (subplebbit.roles !== undefined) { if (subplebbit.roles !== undefined) {
const role = subplebbit.roles[account.author.address]?.role; const role = subplebbit.roles[account?.author?.address]?.role;
if (role === 'moderator' || role === 'admin' || role === 'owner') { if (role === 'moderator' || role === 'admin' || role === 'owner') {
setIsModerator(true); setIsModerator(true);
@@ -641,28 +641,28 @@ const Thread = () => {
</span>) </span>)
: null} : null}
&nbsp; &nbsp;
{comment.author?.displayName {comment?.author?.displayName
? comment.author?.displayName.length > 20 ? comment?.author?.displayName.length > 20
? <> ? <>
<span key={`n-${comment.cid}`} className="name" <span key={`n-${comment.cid}`} className="name"
data-tooltip-id="tooltip" data-tooltip-id="tooltip"
data-tooltip-content={comment.author?.displayName} data-tooltip-content={comment?.author?.displayName}
data-tooltip-place="top"> data-tooltip-place="top">
{comment.author?.displayName.slice(0, 20) + " (...)"} {comment?.author?.displayName.slice(0, 20) + " (...)"}
</span> </span>
</> </>
: <span key={`n-${comment.cid}`} className="name"> : <span key={`n-${comment.cid}`} className="name">
{comment.author?.displayName}</span> {comment?.author?.displayName}</span>
: <span key={`n-${comment.cid}`} className="name"> : <span key={`n-${comment.cid}`} className="name">
Anonymous</span>} Anonymous</span>}
&nbsp; &nbsp;
&nbsp; &nbsp;
<span className="poster-address address-desktop" <span className="poster-address address-desktop"
id="reply-button" style={{cursor: "pointer"}} id="reply-button" style={{cursor: "pointer"}}
onClick={() => handleAddressClick(comment.author?.shortAddress)}> onClick={() => handleAddressClick(comment?.author?.shortAddress)}>
(u/ (u/
<span key={`pa-${comment.cid}`} className="poster-address"> <span key={`pa-${comment.cid}`} className="poster-address">
{comment.author?.shortAddress} {comment?.author?.shortAddress}
</span>) </span>)
</span> </span>
&nbsp; &nbsp;
@@ -712,7 +712,7 @@ const Thread = () => {
style={{ display: rotatedStates[comment.cid] ? 'block' : 'none' }}> style={{ display: rotatedStates[comment.cid] ? 'block' : 'none' }}>
<ul> <ul>
<li onClick={() => handleOptionClick(comment.cid)}>Hide thread</li> <li onClick={() => handleOptionClick(comment.cid)}>Hide thread</li>
{comment.author.shortAddress === account.author.shortAddress ? ( {comment?.author?.shortAddress === account?.author?.shortAddress ? (
<> <>
<li onClick={() => handleOptionClick(comment.cid)}>Edit post</li> <li onClick={() => handleOptionClick(comment.cid)}>Edit post</li>
<li onClick={() => handleOptionClick(comment.cid)}>Delete post</li> <li onClick={() => handleOptionClick(comment.cid)}>Delete post</li>
@@ -720,7 +720,7 @@ const Thread = () => {
) : null} ) : null}
{isModerator ? ( {isModerator ? (
<> <>
{comment.author.shortAddress === account.author.shortAddress ? ( {comment?.author?.shortAddress === account?.author?.shortAddress ? (
null null
) : ( ) : (
<li onClick={() => { <li onClick={() => {
@@ -884,7 +884,7 @@ const Thread = () => {
style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}> style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}>
<ul> <ul>
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li> <li onClick={() => handleOptionClick(reply.cid)}>Hide post</li>
{reply.author.shortAddress === account.author.shortAddress ? ( {reply.author.shortAddress === account?.author?.shortAddress ? (
<> <>
<li onClick={() => handleOptionClick(reply.cid)}>Edit post</li> <li onClick={() => handleOptionClick(reply.cid)}>Edit post</li>
<li onClick={() => handleOptionClick(reply.cid)}>Delete post</li> <li onClick={() => handleOptionClick(reply.cid)}>Delete post</li>
@@ -892,7 +892,7 @@ const Thread = () => {
) : null} ) : null}
{isModerator ? ( {isModerator ? (
<> <>
{reply.author.shortAddress === account.author.shortAddress ? ( {reply.author.shortAddress === account?.author?.shortAddress ? (
null null
) : ( ) : (
<li onClick={() => { <li onClick={() => {
@@ -1038,28 +1038,28 @@ const Thread = () => {
<div key={`mob-pi-${comment.cid}`} className="post-info-mobile"> <div key={`mob-pi-${comment.cid}`} className="post-info-mobile">
<button style={{ all: 'unset', cursor: 'pointer' }} key={`mob-pb-${comment.cid}`} className="post-menu-button-mobile">...</button> <button style={{ all: 'unset', cursor: 'pointer' }} key={`mob-pb-${comment.cid}`} className="post-menu-button-mobile">...</button>
<span className="name-block-mobile"> <span className="name-block-mobile">
{comment.author?.displayName {comment?.author?.displayName
? comment.author?.displayName.length > 15 ? comment?.author?.displayName.length > 15
? <> ? <>
<span key={`mob-n-${comment.cid}`} className="name-mobile" <span key={`mob-n-${comment.cid}`} className="name-mobile"
data-tooltip-id="tooltip" data-tooltip-id="tooltip"
data-tooltip-content={comment.author?.displayName} data-tooltip-content={comment?.author?.displayName}
data-tooltip-place="top"> data-tooltip-place="top">
{comment.author?.displayName.slice(0, 15) + " (...)"} {comment?.author?.displayName.slice(0, 15) + " (...)"}
</span> </span>
</> </>
: <span key={`mob-n-${comment.cid}`} className="name-mobile"> : <span key={`mob-n-${comment.cid}`} className="name-mobile">
{comment.author?.displayName}</span> {comment?.author?.displayName}</span>
: <span key={`mob-n-${comment.cid}`} className="name-mobile"> : <span key={`mob-n-${comment.cid}`} className="name-mobile">
Anonymous</span>} Anonymous</span>}
&nbsp; &nbsp;
<span key={`mob-pa-${comment.cid}`} className="poster-address-mobile address-mobile" <span key={`mob-pa-${comment.cid}`} className="poster-address-mobile address-mobile"
id="reply-button" style={{cursor: "pointer"}} id="reply-button" style={{cursor: "pointer"}}
onClick={() => handleAddressClick(comment.author?.shortAddress)} onClick={() => handleAddressClick(comment?.author?.shortAddress)}
> >
(u/ (u/
<span key={`mob-ha-${comment.cid}`} className="highlight-address-mobile"> <span key={`mob-ha-${comment.cid}`} className="highlight-address-mobile">
{comment.author?.shortAddress} {comment?.author?.shortAddress}
</span> </span>
)&nbsp; )&nbsp;
</span> </span>