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 { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
|
||||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||||
const fallbackImgUrl = 'assets/filedeleted-res.gif';
|
const fallbackImgUrl = 'assets/filedeleted-res.gif';
|
||||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
const canModerate = moderatorPermissions[thread.subplebbitAddress];
|
||||||
let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile;
|
let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile;
|
||||||
if (thread.linkWidth && thread.linkHeight) {
|
if (thread.linkWidth && thread.linkHeight) {
|
||||||
let scale = Math.min(1, 250 / Math.max(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>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -1434,7 +1434,7 @@ const All = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -2019,7 +2019,7 @@ const All = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -2512,7 +2512,7 @@ const All = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
const [commentCid, setCommentCid] = useState(null);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [canModerate, setCanModerate] = useState(false);
|
||||||
|
|
||||||
const [, setNewErrorMessage] = useError();
|
const [, setNewErrorMessage] = useError();
|
||||||
const [, setNewSuccessMessage] = useSuccess();
|
const [, setNewSuccessMessage] = useSuccess();
|
||||||
@@ -161,9 +161,9 @@ const CatalogPost = ({ post }) => {
|
|||||||
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);
|
setCanModerate(true);
|
||||||
} else {
|
} else {
|
||||||
setIsModerator(false);
|
setCanModerate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [account?.author.address, subplebbit.roles]);
|
}, [account?.author.address, subplebbit.roles]);
|
||||||
@@ -573,7 +573,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ const Board = () => {
|
|||||||
const [deletePost, setDeletePost] = useState(false);
|
const [deletePost, setDeletePost] = useState(false);
|
||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [canModerate, setCanModerate] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
const [commentCid, setCommentCid] = useState(null);
|
||||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||||
const [mobileMenuPosition, setMobileMenuPosition] = 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;
|
const role = subplebbit?.roles[account?.author.address]?.role;
|
||||||
|
|
||||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||||
setIsModerator(true);
|
setCanModerate(true);
|
||||||
} else {
|
} else {
|
||||||
setIsModerator(false);
|
setCanModerate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [account?.author.address, subplebbit?.roles]);
|
}, [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' }}>
|
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change rules
|
change rules
|
||||||
</>
|
</>
|
||||||
@@ -1264,7 +1264,7 @@ const Board = () => {
|
|||||||
>
|
>
|
||||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change rules
|
change rules
|
||||||
</>
|
</>
|
||||||
@@ -1509,7 +1509,7 @@ const Board = () => {
|
|||||||
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
||||||
>
|
>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change description
|
change description
|
||||||
</>
|
</>
|
||||||
@@ -2080,7 +2080,7 @@ const Board = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -2465,7 +2465,7 @@ const Board = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -3057,7 +3057,7 @@ const Board = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -3562,7 +3562,7 @@ const Board = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
setIsAuthorEdit,
|
setIsAuthorEdit,
|
||||||
setIsCaptchaOpen,
|
setIsCaptchaOpen,
|
||||||
setIsEditModalOpen,
|
setIsEditModalOpen,
|
||||||
isModerator,
|
canModerate,
|
||||||
setModeratingCommentCid,
|
setModeratingCommentCid,
|
||||||
setOriginalCommentContent,
|
setOriginalCommentContent,
|
||||||
setPendingComment,
|
setPendingComment,
|
||||||
@@ -443,7 +443,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
>
|
>
|
||||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change rules
|
change rules
|
||||||
</>
|
</>
|
||||||
@@ -647,7 +647,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
>
|
>
|
||||||
<div className={`post-menu-thread post-menu-thread-${'description'}`} style={{ display: openMenuCid === 'description' ? 'block' : 'none' }}>
|
<div className={`post-menu-thread post-menu-thread-${'description'}`} style={{ display: openMenuCid === 'description' ? 'block' : 'none' }}>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change description
|
change description
|
||||||
</>
|
</>
|
||||||
@@ -999,7 +999,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -1133,7 +1133,7 @@ const Catalog = () => {
|
|||||||
setIsCaptchaOpen,
|
setIsCaptchaOpen,
|
||||||
isModerationOpen,
|
isModerationOpen,
|
||||||
setIsModerationOpen,
|
setIsModerationOpen,
|
||||||
setIsModerator,
|
setCanModerate,
|
||||||
isSettingsOpen,
|
isSettingsOpen,
|
||||||
setIsSettingsOpen,
|
setIsSettingsOpen,
|
||||||
originalCommentContent,
|
originalCommentContent,
|
||||||
@@ -1198,12 +1198,12 @@ const Catalog = () => {
|
|||||||
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);
|
setCanModerate(true);
|
||||||
} else {
|
} else {
|
||||||
setIsModerator(false);
|
setCanModerate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [account?.author.address, subplebbit.roles, setIsModerator]);
|
}, [account?.author.address, subplebbit.roles, setCanModerate]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedAddress(subplebbitAddress);
|
setSelectedAddress(subplebbitAddress);
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ const Description = () => {
|
|||||||
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
||||||
>
|
>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change description
|
change description
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ const Rules = () => {
|
|||||||
>
|
>
|
||||||
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
<div className={`post-menu-thread post-menu-thread-${'rules'}`} style={{ display: openMenuCid === 'rules' ? 'block' : 'none' }}>
|
||||||
<ul className='post-menu-catalog'>
|
<ul className='post-menu-catalog'>
|
||||||
{/* {isModerator ? (
|
{/* {canModerate ? (
|
||||||
<>
|
<>
|
||||||
change rules
|
change rules
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ const Subscriptions = () => {
|
|||||||
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
|
const { displayedReplies, omittedCount } = filteredRepliesByThread[thread.cid] || {};
|
||||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||||
const fallbackImgUrl = 'assets/filedeleted-res.gif';
|
const fallbackImgUrl = 'assets/filedeleted-res.gif';
|
||||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
const canModerate = moderatorPermissions[thread.subplebbitAddress];
|
||||||
let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile;
|
let displayWidth, displayHeight, displayWidthMobile, displayHeightMobile;
|
||||||
if (thread.linkWidth && thread.linkHeight) {
|
if (thread.linkWidth && thread.linkHeight) {
|
||||||
let scale = Math.min(1, 250 / Math.max(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>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -1444,7 +1444,7 @@ const Subscriptions = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -2029,7 +2029,7 @@ const Subscriptions = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -2522,7 +2522,7 @@ const Subscriptions = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
const [commentCid, setCommentCid] = useState(null);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [canModerate, setCanModerate] = useState(false);
|
||||||
|
|
||||||
const [, setNewErrorMessage] = useError();
|
const [, setNewErrorMessage] = useError();
|
||||||
const [, setNewSuccessMessage] = useSuccess();
|
const [, setNewSuccessMessage] = useSuccess();
|
||||||
@@ -161,9 +161,9 @@ const CatalogPost = ({ post }) => {
|
|||||||
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);
|
setCanModerate(true);
|
||||||
} else {
|
} else {
|
||||||
setIsModerator(false);
|
setCanModerate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [account?.author.address, subplebbit.roles]);
|
}, [account?.author.address, subplebbit.roles]);
|
||||||
@@ -573,7 +573,7 @@ const CatalogPost = ({ post }) => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ const Thread = () => {
|
|||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
const [isClientRedirectMenuOpen, setIsClientRedirectMenuOpen] = useState(false);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [canModerate, setCanModerate] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
const [commentCid, setCommentCid] = useState(null);
|
||||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||||
const [mobileMenuPosition, setMobileMenuPosition] = 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;
|
const role = subplebbit.roles[account?.author?.address]?.role;
|
||||||
|
|
||||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||||
setIsModerator(true);
|
setCanModerate(true);
|
||||||
} else {
|
} else {
|
||||||
setIsModerator(false);
|
setCanModerate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [account?.author.address, subplebbit.roles]);
|
}, [account?.author.address, subplebbit.roles]);
|
||||||
@@ -1205,7 +1205,7 @@ const Thread = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(comment)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(comment)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -1531,7 +1531,7 @@ const Thread = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -1986,7 +1986,7 @@ const Thread = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(comment)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(comment)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
@@ -2398,7 +2398,7 @@ const Thread = () => {
|
|||||||
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
<li onClick={() => handleAuthorDeleteClick(reply)}>Delete post</li>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
{isModerator ? (
|
{canModerate ? (
|
||||||
<>
|
<>
|
||||||
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
{authorAddress === account?.author.address || authorAddress === account?.signer.address ? null : (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -30,12 +30,13 @@ const useGeneralStore = create((set) => ({
|
|||||||
setEditedComments: (comments) => set({ editedComments: comments }),
|
setEditedComments: (comments) => set({ editedComments: comments }),
|
||||||
|
|
||||||
feedCacheStates: {},
|
feedCacheStates: {},
|
||||||
setFeedCacheState: (address, isCached) => set((prev) => ({
|
setFeedCacheState: (address, isCached) =>
|
||||||
feedCacheStates: {
|
set((prev) => ({
|
||||||
...prev.feedCacheStates,
|
feedCacheStates: {
|
||||||
[address]: isCached,
|
...prev.feedCacheStates,
|
||||||
}
|
[address]: isCached,
|
||||||
})),
|
},
|
||||||
|
})),
|
||||||
|
|
||||||
isAuthorDelete: false,
|
isAuthorDelete: false,
|
||||||
setIsAuthorDelete: (isAuthorDelete) => set({ isAuthorDelete }),
|
setIsAuthorDelete: (isAuthorDelete) => set({ isAuthorDelete }),
|
||||||
@@ -49,8 +50,8 @@ const useGeneralStore = create((set) => ({
|
|||||||
isEditModalOpen: false,
|
isEditModalOpen: false,
|
||||||
setIsEditModalOpen: (isOpen) => set({ isEditModalOpen: isOpen }),
|
setIsEditModalOpen: (isOpen) => set({ isEditModalOpen: isOpen }),
|
||||||
|
|
||||||
isModerator: false,
|
canModerate: false,
|
||||||
setIsModerator: (isModerator) => set({ isModerator }),
|
setCanModerate: (canModerate) => set({ canModerate }),
|
||||||
|
|
||||||
isModerationOpen: false,
|
isModerationOpen: false,
|
||||||
setIsModerationOpen: (isOpen) => set({ isModerationOpen: isOpen }),
|
setIsModerationOpen: (isOpen) => set({ isModerationOpen: isOpen }),
|
||||||
@@ -81,7 +82,7 @@ const useGeneralStore = create((set) => ({
|
|||||||
|
|
||||||
resolveCaptchaPromise: null,
|
resolveCaptchaPromise: null,
|
||||||
setResolveCaptchaPromise: (resolve) => set({ resolveCaptchaPromise: resolve }),
|
setResolveCaptchaPromise: (resolve) => set({ resolveCaptchaPromise: resolve }),
|
||||||
|
|
||||||
selectedAddress: '',
|
selectedAddress: '',
|
||||||
setSelectedAddress: (address) => set({ selectedAddress: address }),
|
setSelectedAddress: (address) => set({ selectedAddress: address }),
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ const useGeneralStore = create((set) => ({
|
|||||||
|
|
||||||
selectedShortCid: '',
|
selectedShortCid: '',
|
||||||
setSelectedShortCid: (shortCid) => set({ selectedShortCid: shortCid }),
|
setSelectedShortCid: (shortCid) => set({ selectedShortCid: shortCid }),
|
||||||
|
|
||||||
selectedStyle: localStorage.getItem('selectedStyle') || 'Yotsuba',
|
selectedStyle: localStorage.getItem('selectedStyle') || 'Yotsuba',
|
||||||
setSelectedStyle: (style) => {
|
setSelectedStyle: (style) => {
|
||||||
localStorage.setItem('selectedStyle', style);
|
localStorage.setItem('selectedStyle', style);
|
||||||
@@ -99,7 +100,7 @@ const useGeneralStore = create((set) => ({
|
|||||||
|
|
||||||
selectedText: '',
|
selectedText: '',
|
||||||
setSelectedText: (text) => set({ selectedText: text }),
|
setSelectedText: (text) => set({ selectedText: text }),
|
||||||
|
|
||||||
selectedThread: '',
|
selectedThread: '',
|
||||||
setSelectedThread: (thread) => set({ selectedThread: thread }),
|
setSelectedThread: (thread) => set({ selectedThread: thread }),
|
||||||
|
|
||||||
@@ -114,7 +115,6 @@ const useGeneralStore = create((set) => ({
|
|||||||
|
|
||||||
triggerInsertion: 0,
|
triggerInsertion: 0,
|
||||||
setTriggerInsertion: (trigger) => set({ triggerInsertion: trigger }),
|
setTriggerInsertion: (trigger) => set({ triggerInsertion: trigger }),
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default useGeneralStore;
|
export default useGeneralStore;
|
||||||
|
|||||||
Reference in New Issue
Block a user