mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(state): rename isModerator to canModerate for precision
This commit is contained in:
@@ -717,7 +717,7 @@ const All = () => {
|
||||
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = 'assets/filedeleted-res.gif';
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const canModerate = moderatorPermissions[thread.subplebbitAddress];
|
||||
let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile;
|
||||
if (thread.linkWidth && thread.linkHeight) {
|
||||
let scale = Math.min(1, 250 / Math.max(thread.linkWidth, thread.linkHeight));
|
||||
@@ -1037,7 +1037,7 @@ const All = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -1434,7 +1434,7 @@ const All = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -2019,7 +2019,7 @@ const All = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -2512,7 +2512,7 @@ const All = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
|
||||
@@ -69,7 +69,7 @@ const CatalogPost = ({ post }) => {
|
||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||
const [commentCid, setCommentCid] = useState(null);
|
||||
const [isModerator, setIsModerator] = useState(false);
|
||||
const [canModerate, setCanModerate] = useState(false);
|
||||
|
||||
const [, setNewErrorMessage] = useError();
|
||||
const [, setNewSuccessMessage] = useSuccess();
|
||||
@@ -161,9 +161,9 @@ const CatalogPost = ({ post }) => {
|
||||
const role = subplebbit.roles[account?.author.address]?.role;
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
setIsModerator(true);
|
||||
setCanModerate(true);
|
||||
} else {
|
||||
setIsModerator(false);
|
||||
setCanModerate(false);
|
||||
}
|
||||
}
|
||||
}, [account?.author.address, subplebbit.roles]);
|
||||
@@ -573,7 +573,7 @@ const CatalogPost = ({ post }) => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
|
||||
@@ -145,7 +145,7 @@ const Board = () => {
|
||||
const [deletePost, setDeletePost] = useState(false);
|
||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||
const [isModerator, setIsModerator] = useState(false);
|
||||
const [canModerate, setCanModerate] = useState(false);
|
||||
const [commentCid, setCommentCid] = useState(null);
|
||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||
const [mobileMenuPosition, setMobileMenuPosition] = useState({ top: 0, left: 0 });
|
||||
@@ -180,9 +180,9 @@ const Board = () => {
|
||||
const role = subplebbit?.roles[account?.author.address]?.role;
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
setIsModerator(true);
|
||||
setCanModerate(true);
|
||||
} else {
|
||||
setIsModerator(false);
|
||||
setCanModerate(false);
|
||||
}
|
||||
}
|
||||
}, [account?.author.address, subplebbit?.roles]);
|
||||
@@ -1039,7 +1039,7 @@ const Board = () => {
|
||||
>
|
||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change rules
|
||||
</>
|
||||
@@ -1264,7 +1264,7 @@ const Board = () => {
|
||||
>
|
||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change rules
|
||||
</>
|
||||
@@ -1509,7 +1509,7 @@ const Board = () => {
|
||||
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
||||
>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change description
|
||||
</>
|
||||
@@ -2080,7 +2080,7 @@ const Board = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -2465,7 +2465,7 @@ const Board = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -3057,7 +3057,7 @@ const Board = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -3562,7 +3562,7 @@ const Board = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
|
||||
@@ -52,7 +52,7 @@ const CatalogPost = ({ post }) => {
|
||||
setIsAuthorEdit,
|
||||
setIsCaptchaOpen,
|
||||
setIsEditModalOpen,
|
||||
isModerator,
|
||||
canModerate,
|
||||
setModeratingCommentCid,
|
||||
setOriginalCommentContent,
|
||||
setPendingComment,
|
||||
@@ -443,7 +443,7 @@ const CatalogPost = ({ post }) => {
|
||||
>
|
||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change rules
|
||||
</>
|
||||
@@ -647,7 +647,7 @@ const CatalogPost = ({ post }) => {
|
||||
>
|
||||
<div className={`post-menu-thread post-menu-thread-${'description'}`} style={{ display: openMenuCid === 'description' ? 'block' : 'none' }}>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change description
|
||||
</>
|
||||
@@ -999,7 +999,7 @@ const CatalogPost = ({ post }) => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -1133,7 +1133,7 @@ const Catalog = () => {
|
||||
setIsCaptchaOpen,
|
||||
isModerationOpen,
|
||||
setIsModerationOpen,
|
||||
setIsModerator,
|
||||
setCanModerate,
|
||||
isSettingsOpen,
|
||||
setIsSettingsOpen,
|
||||
originalCommentContent,
|
||||
@@ -1198,12 +1198,12 @@ const Catalog = () => {
|
||||
const role = subplebbit.roles[account?.author.address]?.role;
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
setIsModerator(true);
|
||||
setCanModerate(true);
|
||||
} else {
|
||||
setIsModerator(false);
|
||||
setCanModerate(false);
|
||||
}
|
||||
}
|
||||
}, [account?.author.address, subplebbit.roles, setIsModerator]);
|
||||
}, [account?.author.address, subplebbit.roles, setCanModerate]);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedAddress(subplebbitAddress);
|
||||
|
||||
@@ -427,7 +427,7 @@ const Description = () => {
|
||||
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
||||
>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change description
|
||||
</>
|
||||
|
||||
@@ -412,7 +412,7 @@ const Rules = () => {
|
||||
>
|
||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||
<ul className='post-menu-catalog'>
|
||||
{/* {isModerator ? (
|
||||
{/* {canModerate ? (
|
||||
<>
|
||||
change rules
|
||||
</>
|
||||
|
||||
@@ -721,7 +721,7 @@ const Subscriptions = () => {
|
||||
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = 'assets/filedeleted-res.gif';
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const canModerate = moderatorPermissions[thread.subplebbitAddress];
|
||||
let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile;
|
||||
if (thread.linkWidth && thread.linkHeight) {
|
||||
let scale = Math.min(1, 250 / Math.max(thread.linkWidth, thread.linkHeight));
|
||||
@@ -1047,7 +1047,7 @@ const Subscriptions = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -1444,7 +1444,7 @@ const Subscriptions = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -2029,7 +2029,7 @@ const Subscriptions = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -2522,7 +2522,7 @@ const Subscriptions = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
|
||||
@@ -69,7 +69,7 @@ const CatalogPost = ({ post }) => {
|
||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||
const [commentCid, setCommentCid] = useState(null);
|
||||
const [isModerator, setIsModerator] = useState(false);
|
||||
const [canModerate, setCanModerate] = useState(false);
|
||||
|
||||
const [, setNewErrorMessage] = useError();
|
||||
const [, setNewSuccessMessage] = useSuccess();
|
||||
@@ -161,9 +161,9 @@ const CatalogPost = ({ post }) => {
|
||||
const role = subplebbit.roles[account?.author.address]?.role;
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
setIsModerator(true);
|
||||
setCanModerate(true);
|
||||
} else {
|
||||
setIsModerator(false);
|
||||
setCanModerate(false);
|
||||
}
|
||||
}
|
||||
}, [account?.author.address, subplebbit.roles]);
|
||||
@@ -573,7 +573,7 @@ const CatalogPost = ({ post }) => {
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
|
||||
@@ -119,7 +119,7 @@ const Thread = () => {
|
||||
const [visible, setVisible] = useState(true);
|
||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||
const [isModerator, setIsModerator] = useState(false);
|
||||
const [canModerate, setCanModerate] = useState(false);
|
||||
const [commentCid, setCommentCid] = useState(null);
|
||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||
const [mobileMenuPosition, setMobileMenuPosition] = useState({ top: 0, left: 0 });
|
||||
@@ -200,9 +200,9 @@ const Thread = () => {
|
||||
const role = subplebbit.roles[account?.author?.address]?.role;
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
setIsModerator(true);
|
||||
setCanModerate(true);
|
||||
} else {
|
||||
setIsModerator(false);
|
||||
setCanModerate(false);
|
||||
}
|
||||
}
|
||||
}, [account?.author.address, subplebbit.roles]);
|
||||
@@ -1205,7 +1205,7 @@ const Thread = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(comment)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -1531,7 +1531,7 @@ const Thread = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -1986,7 +1986,7 @@ const Thread = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(comment)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
@@ -2398,7 +2398,7 @@ const Thread = () => {
|
||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
{canModerate ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||
<li
|
||||
|
||||
Reference in New Issue
Block a user