mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
update moderation
This commit is contained in:
@@ -8,7 +8,7 @@ import useError from "../hooks/useError";
|
|||||||
import useSuccess from "../hooks/useSuccess";
|
import useSuccess from "../hooks/useSuccess";
|
||||||
|
|
||||||
|
|
||||||
const ModerationModal = ({ isOpen, closeModal }) => {
|
const ModerationModal = ({ isOpen, closeModal, deletePost }) => {
|
||||||
const {
|
const {
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
selectedStyle,
|
selectedStyle,
|
||||||
@@ -20,7 +20,7 @@ const ModerationModal = ({ isOpen, closeModal }) => {
|
|||||||
} = useGeneralStore(state => state);
|
} = useGeneralStore(state => state);
|
||||||
|
|
||||||
const [pin, setPin] = useState(false);
|
const [pin, setPin] = useState(false);
|
||||||
const [deleteThread, setDeleteThread] = useState(false);
|
const [deleteThread, setDeleteThread] = useState(deletePost);
|
||||||
const [close, setClose] = useState(false);
|
const [close, setClose] = useState(false);
|
||||||
const [reason, setReason] = useState('');
|
const [reason, setReason] = useState('');
|
||||||
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
|
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
|
||||||
@@ -30,7 +30,19 @@ const ModerationModal = ({ isOpen, closeModal }) => {
|
|||||||
useError(errorMessage, [errorMessage]);
|
useError(errorMessage, [errorMessage]);
|
||||||
useSuccess(successMessage, [successMessage]);
|
useSuccess(successMessage, [successMessage]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setDeleteThread(deletePost);
|
||||||
|
}, [deletePost]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isOpen) {
|
||||||
|
setDeleteThread(deletePost);
|
||||||
|
}
|
||||||
|
}, [isOpen, deletePost]);
|
||||||
|
|
||||||
const handleCloseModal = () => {
|
const handleCloseModal = () => {
|
||||||
|
setDeleteThread(false);
|
||||||
closeModal();
|
closeModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,11 +167,11 @@ const ModerationModal = ({ isOpen, closeModal }) => {
|
|||||||
<label>
|
<label>
|
||||||
<input type="checkbox" style={{marginRight: "10px"}}
|
<input type="checkbox" style={{marginRight: "10px"}}
|
||||||
checked={pin} onChange={() => setPin(!pin)} />
|
checked={pin} onChange={() => setPin(!pin)} />
|
||||||
Pin thread
|
Pin post
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li className="settings-tip">
|
<li className="settings-tip">
|
||||||
Pin the thread to make it a sticky, showed at the top of the board even as new posts are submitted.
|
Pin the post to make it a sticky, showed at the top of the board even as new posts are submitted.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="settings-cat">
|
<ul className="settings-cat">
|
||||||
@@ -167,7 +179,7 @@ const ModerationModal = ({ isOpen, closeModal }) => {
|
|||||||
<label>
|
<label>
|
||||||
<input type="checkbox" style={{marginRight: "10px"}}
|
<input type="checkbox" style={{marginRight: "10px"}}
|
||||||
checked={deleteThread} onChange={() => setDeleteThread(!deleteThread)} />
|
checked={deleteThread} onChange={() => setDeleteThread(!deleteThread)} />
|
||||||
Delete thread
|
Delete post
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li className="settings-tip">
|
<li className="settings-tip">
|
||||||
@@ -179,11 +191,11 @@ const ModerationModal = ({ isOpen, closeModal }) => {
|
|||||||
<label>
|
<label>
|
||||||
<input type="checkbox" style={{marginRight: "10px"}}
|
<input type="checkbox" style={{marginRight: "10px"}}
|
||||||
checked={close} onChange={() => setClose(!close)} />
|
checked={close} onChange={() => setClose(!close)} />
|
||||||
Close thread
|
Close post
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li className="settings-tip">
|
<li className="settings-tip">
|
||||||
Closing a thread allows users to still see the content, but they cannot add any new replies to it.
|
Closing a post allows users to still see the content, but they cannot add any new replies to it.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="settings-cat">
|
<ul className="settings-cat">
|
||||||
|
|||||||
+71
-130
@@ -3,7 +3,7 @@ import { Helmet } from 'react-helmet-async';
|
|||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
import { Tooltip } from 'react-tooltip';
|
import { Tooltip } from 'react-tooltip';
|
||||||
import { Virtuoso } from 'react-virtuoso';
|
import { Virtuoso } from 'react-virtuoso';
|
||||||
import { useAccount, useAccountComments, useFeed, usePublishComment, usePublishCommentEdit, useSubplebbit, useSubscribe } from '@plebbit/plebbit-react-hooks';
|
import { useAccount, useAccountComments, useFeed, usePublishComment, useSubplebbit, useSubscribe } from '@plebbit/plebbit-react-hooks';
|
||||||
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils'
|
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils'
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||||
@@ -73,13 +73,12 @@ const Board = () => {
|
|||||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
|
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
|
||||||
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
|
|
||||||
const [selectedFeed, setSelectedFeed] = useState(feed);
|
const [selectedFeed, setSelectedFeed] = useState(feed);
|
||||||
|
const [deletePost, setDeletePost] = useState(false);
|
||||||
const [rotatedStates, setRotatedStates] = useState({});
|
const [rotatedStates, setRotatedStates] = useState({});
|
||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [isModerator, setIsModerator] = useState(false);
|
||||||
const [isModToolsOpen, setIsModToolsOpen] = useState(false);
|
const [isModToolsOpen, setIsModToolsOpen] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
|
||||||
|
|
||||||
const [errorMessage, setErrorMessage] = useState(null);
|
const [errorMessage, setErrorMessage] = useState(null);
|
||||||
const [successMessage, setSuccessMessage] = useState(null);
|
const [successMessage, setSuccessMessage] = useState(null);
|
||||||
@@ -362,76 +361,6 @@ const Board = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({
|
|
||||||
commentCid: commentCid,
|
|
||||||
subplebbitAddress: selectedAddress,
|
|
||||||
onChallenge,
|
|
||||||
onChallengeVerification,
|
|
||||||
onError: (error) => {
|
|
||||||
setErrorMessage(error);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const {error, publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (error) {
|
|
||||||
setErrorMessage(error);
|
|
||||||
}
|
|
||||||
}, [error]);
|
|
||||||
|
|
||||||
|
|
||||||
const handleModToolClick = (tool, commentCid, currentState) => {
|
|
||||||
setCommentCid(commentCid);
|
|
||||||
handleOptionClick(commentCid);
|
|
||||||
|
|
||||||
switch (tool) {
|
|
||||||
case 'Pin':
|
|
||||||
case 'Unpin':
|
|
||||||
setPublishCommentEditOptions(prevOptions => ({
|
|
||||||
...prevOptions,
|
|
||||||
pinned: !currentState.pinned,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
case 'Close':
|
|
||||||
case 'Reopen':
|
|
||||||
setPublishCommentEditOptions(prevOptions => ({
|
|
||||||
...prevOptions,
|
|
||||||
locked: !currentState.locked,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
case 'Delete':
|
|
||||||
setPublishCommentEditOptions(prevOptions => ({
|
|
||||||
...prevOptions,
|
|
||||||
removed: true,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTriggerPublishCommentEdit(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setPublishCommentEditOptions((prevOptions) => ({
|
|
||||||
...prevOptions,
|
|
||||||
commentCid: commentCid,
|
|
||||||
}));
|
|
||||||
}, [commentCid]);
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (publishCommentEditOptions && triggerPublishCommentEdit) {
|
|
||||||
(async () => {
|
|
||||||
await publishCommentEdit();
|
|
||||||
setTriggerPublishCommentEdit(false);
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
}, [publishCommentEditOptions, triggerPublishCommentEdit, publishCommentEdit]);
|
|
||||||
|
|
||||||
|
|
||||||
// desktop navbar board select functionality
|
// desktop navbar board select functionality
|
||||||
const handleClickTitle = (title, address) => {
|
const handleClickTitle = (title, address) => {
|
||||||
@@ -493,7 +422,8 @@ const Board = () => {
|
|||||||
<ModerationModal
|
<ModerationModal
|
||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isModerationOpen}
|
isOpen={isModerationOpen}
|
||||||
closeModal={() => setIsModerationOpen(false)} />
|
closeModal={() => setIsModerationOpen(false)}
|
||||||
|
deletePost={deletePost} />
|
||||||
<NavBar selectedStyle={selectedStyle}>
|
<NavBar selectedStyle={selectedStyle}>
|
||||||
<>
|
<>
|
||||||
<span className="boardList">
|
<span className="boardList">
|
||||||
@@ -828,8 +758,39 @@ const Board = () => {
|
|||||||
<div id="post-menu" className={`post-menu-thread post-menu-thread-${thread.cid}`}
|
<div id="post-menu" className={`post-menu-thread post-menu-thread-${thread.cid}`}
|
||||||
style={{ display: rotatedStates[thread.cid] ? 'block' : 'none' }}>
|
style={{ display: rotatedStates[thread.cid] ? 'block' : 'none' }}>
|
||||||
<ul>
|
<ul>
|
||||||
{/* <li onClick={() => handleOptionClick(thread.cid)}>Edit post</li> */}
|
|
||||||
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li>
|
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li>
|
||||||
|
{thread.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
<>
|
||||||
|
<li onClick={() => handleOptionClick(thread.cid)}>Edit post</li>
|
||||||
|
<li onClick={() => handleOptionClick(thread.cid)}>Delete post</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{isModerator ? (
|
||||||
|
<>
|
||||||
|
{thread.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
null
|
||||||
|
) : (
|
||||||
|
<li onClick={() => {
|
||||||
|
setModeratingCommentCid(thread.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(thread.cid);
|
||||||
|
setDeletePost(true);
|
||||||
|
}}>
|
||||||
|
Delete post
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
<li
|
||||||
|
onMouseOver={() => {setIsModToolsOpen(true)}}
|
||||||
|
onMouseLeave={() => {setIsModToolsOpen(false)}}
|
||||||
|
onClick={() => {
|
||||||
|
setModeratingCommentCid(thread.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(thread.cid);
|
||||||
|
}}>
|
||||||
|
Mod tools
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{(commentMediaInfo && (
|
{(commentMediaInfo && (
|
||||||
commentMediaInfo.type === 'image' ||
|
commentMediaInfo.type === 'image' ||
|
||||||
(commentMediaInfo.type === 'webpage' &&
|
(commentMediaInfo.type === 'webpage' &&
|
||||||
@@ -862,42 +823,6 @@ const Board = () => {
|
|||||||
</li>
|
</li>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
{isModerator ? (
|
|
||||||
<li
|
|
||||||
onMouseOver={() => {setIsModToolsOpen(true)}}
|
|
||||||
onMouseLeave={() => {setIsModToolsOpen(false)}}>
|
|
||||||
Mod tools »
|
|
||||||
<ul className="dropdown-menu"
|
|
||||||
style={{display: isModToolsOpen ? 'block': 'none'}}>
|
|
||||||
<li onClick={() => {
|
|
||||||
setModeratingCommentCid(thread.cid);
|
|
||||||
setIsModerationOpen(true);
|
|
||||||
handleOptionClick(thread.cid);
|
|
||||||
}}>
|
|
||||||
Open tools ↗
|
|
||||||
</li>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
thread.pinned ? 'Unpin' : 'Pin',
|
|
||||||
thread.cid,
|
|
||||||
{ pinned: thread.pinned, locked: thread.locked }
|
|
||||||
)}>
|
|
||||||
{thread.pinned ? 'Unpin' : 'Pin'}
|
|
||||||
</li>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
thread.locked ? 'Reopen' : 'Close',
|
|
||||||
thread.cid,
|
|
||||||
{ pinned: thread.pinned, locked: thread.locked }
|
|
||||||
)}>
|
|
||||||
{thread.locked ? 'Reopen' : 'Close'}
|
|
||||||
</li>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
'Delete', thread.cid
|
|
||||||
)}>
|
|
||||||
Delete
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
) : null}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div key={`bi-${index}`} id="backlink-id" className="backlink">
|
<div key={`bi-${index}`} id="backlink-id" className="backlink">
|
||||||
@@ -1034,8 +959,39 @@ const Board = () => {
|
|||||||
<div id="post-menu" className={`post-menu-reply post-menu-reply-${reply.cid}`}
|
<div id="post-menu" className={`post-menu-reply post-menu-reply-${reply.cid}`}
|
||||||
style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}>
|
style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}>
|
||||||
<ul>
|
<ul>
|
||||||
{/* <li onClick={() => handleOptionClick(reply.cid)}>Edit post</li> */}
|
|
||||||
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li>
|
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li>
|
||||||
|
{reply.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
<>
|
||||||
|
<li onClick={() => handleOptionClick(reply.cid)}>Edit post</li>
|
||||||
|
<li onClick={() => handleOptionClick(reply.cid)}>Delete post</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{isModerator ? (
|
||||||
|
<>
|
||||||
|
{reply.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
null
|
||||||
|
) : (
|
||||||
|
<li onClick={() => {
|
||||||
|
setModeratingCommentCid(reply.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(reply.cid);
|
||||||
|
setDeletePost(true);
|
||||||
|
}}>
|
||||||
|
Delete post
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
<li
|
||||||
|
onMouseOver={() => {setIsModToolsOpen(true)}}
|
||||||
|
onMouseLeave={() => {setIsModToolsOpen(false)}}
|
||||||
|
onClick={() => {
|
||||||
|
setModeratingCommentCid(reply.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(reply.cid);
|
||||||
|
}}>
|
||||||
|
Mod tools
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{(replyMediaInfo && (
|
{(replyMediaInfo && (
|
||||||
replyMediaInfo.type === 'image' ||
|
replyMediaInfo.type === 'image' ||
|
||||||
(replyMediaInfo.type === 'webpage' &&
|
(replyMediaInfo.type === 'webpage' &&
|
||||||
@@ -1048,19 +1004,19 @@ const Board = () => {
|
|||||||
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
||||||
<li onClick={() => handleOptionClick(reply.cid)}>
|
<li onClick={() => handleOptionClick(reply.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo?.url}`}
|
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>Google</a>
|
>Google</a>
|
||||||
</li>
|
</li>
|
||||||
<li onClick={() => handleOptionClick(reply.cid)}>
|
<li onClick={() => handleOptionClick(reply.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://yandex.com/images/search?url=${commentMediaInfo?.url}`}
|
href={`https://yandex.com/images/search?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>Yandex</a>
|
>Yandex</a>
|
||||||
</li>
|
</li>
|
||||||
<li onClick={() => handleOptionClick(reply.cid)}>
|
<li onClick={() => handleOptionClick(reply.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://saucenao.com/search.php?url=${commentMediaInfo?.url}`}
|
href={`https://saucenao.com/search.php?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>SauceNAO</a>
|
>SauceNAO</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -1068,21 +1024,6 @@ const Board = () => {
|
|||||||
</li>
|
</li>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
{isModerator ? (
|
|
||||||
<li
|
|
||||||
onMouseOver={() => {setIsModToolsOpen(true)}}
|
|
||||||
onMouseLeave={() => {setIsModToolsOpen(false)}}>
|
|
||||||
Mod tools »
|
|
||||||
<ul className="dropdown-menu"
|
|
||||||
style={{display: isModToolsOpen ? 'block': 'none'}}>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
'Delete', reply.cid
|
|
||||||
)}>
|
|
||||||
Delete
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
) : null}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="backlink-id" className="backlink">
|
<div id="backlink-id" className="backlink">
|
||||||
|
|||||||
+75
-134
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|||||||
import { Helmet } from 'react-helmet-async';
|
import { Helmet } from 'react-helmet-async';
|
||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
import { Tooltip } from 'react-tooltip';
|
import { Tooltip } from 'react-tooltip';
|
||||||
import { useAccount, useAccountComments, useComment, usePublishComment, usePublishCommentEdit, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
import { useAccount, useAccountComments, useComment, usePublishComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||||
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils'
|
import { flattenCommentsPages } from '@plebbit/plebbit-react-hooks/dist/lib/utils'
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||||
@@ -63,7 +63,7 @@ const Thread = () => {
|
|||||||
const replyMenuRefs = useRef({});
|
const replyMenuRefs = useRef({});
|
||||||
|
|
||||||
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
|
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
|
||||||
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
|
const [deletePost, setDeletePost] = useState(false);
|
||||||
const [errorMessage, setErrorMessage] = useState(null);
|
const [errorMessage, setErrorMessage] = useState(null);
|
||||||
const [successMessage, setSuccessMessage] = useState(null);
|
const [successMessage, setSuccessMessage] = useState(null);
|
||||||
const [isReplyOpen, setIsReplyOpen] = useState(false);
|
const [isReplyOpen, setIsReplyOpen] = useState(false);
|
||||||
@@ -73,7 +73,6 @@ const Thread = () => {
|
|||||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
const [isModerator, setIsModerator] = useState(false);
|
const [isModerator, setIsModerator] = useState(false);
|
||||||
const [isModToolsOpen, setIsModToolsOpen] = useState(false);
|
const [isModToolsOpen, setIsModToolsOpen] = useState(false);
|
||||||
const [commentCid, setCommentCid] = useState(null);
|
|
||||||
|
|
||||||
useError(errorMessage, [errorMessage]);
|
useError(errorMessage, [errorMessage]);
|
||||||
useSuccess(successMessage, [successMessage]);
|
useSuccess(successMessage, [successMessage]);
|
||||||
@@ -332,76 +331,6 @@ const Thread = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({
|
|
||||||
commentCid: commentCid,
|
|
||||||
subplebbitAddress: selectedAddress,
|
|
||||||
onChallenge,
|
|
||||||
onChallengeVerification,
|
|
||||||
onError: (error) => {
|
|
||||||
setErrorMessage(error);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const {error, publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (error) {
|
|
||||||
setErrorMessage(error);
|
|
||||||
}
|
|
||||||
}, [error]);
|
|
||||||
|
|
||||||
|
|
||||||
const handleModToolClick = (tool, commentCid, currentState) => {
|
|
||||||
setCommentCid(commentCid);
|
|
||||||
handleOptionClick(commentCid);
|
|
||||||
|
|
||||||
switch (tool) {
|
|
||||||
case 'Pin':
|
|
||||||
case 'Unpin':
|
|
||||||
setPublishCommentEditOptions(prevOptions => ({
|
|
||||||
...prevOptions,
|
|
||||||
pinned: !currentState.pinned,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
case 'Close':
|
|
||||||
case 'Reopen':
|
|
||||||
setPublishCommentEditOptions(prevOptions => ({
|
|
||||||
...prevOptions,
|
|
||||||
locked: !currentState.locked,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
case 'Delete':
|
|
||||||
setPublishCommentEditOptions(prevOptions => ({
|
|
||||||
...prevOptions,
|
|
||||||
removed: true,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTriggerPublishCommentEdit(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setPublishCommentEditOptions((prevOptions) => ({
|
|
||||||
...prevOptions,
|
|
||||||
commentCid: commentCid,
|
|
||||||
}));
|
|
||||||
}, [commentCid]);
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (publishCommentEditOptions && triggerPublishCommentEdit) {
|
|
||||||
(async () => {
|
|
||||||
await publishCommentEdit();
|
|
||||||
setTriggerPublishCommentEdit(false);
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
}, [publishCommentEditOptions, triggerPublishCommentEdit, publishCommentEdit]);
|
|
||||||
|
|
||||||
// mobile navbar board select functionality
|
// mobile navbar board select functionality
|
||||||
const handleSelectChange = (event) => {
|
const handleSelectChange = (event) => {
|
||||||
const selected = event.target.value;
|
const selected = event.target.value;
|
||||||
@@ -444,7 +373,8 @@ const Thread = () => {
|
|||||||
<ModerationModal
|
<ModerationModal
|
||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isModerationOpen}
|
isOpen={isModerationOpen}
|
||||||
closeModal={() => setIsModerationOpen(false)} />
|
closeModal={() => setIsModerationOpen(false)}
|
||||||
|
deletePost={deletePost} />
|
||||||
<NavBar selectedStyle={selectedStyle}>
|
<NavBar selectedStyle={selectedStyle}>
|
||||||
<>
|
<>
|
||||||
<span className="boardList">
|
<span className="boardList">
|
||||||
@@ -782,8 +712,39 @@ const Thread = () => {
|
|||||||
<div id="post-menu" className={`post-menu-thread post-menu-thread-${comment.cid}`}
|
<div id="post-menu" className={`post-menu-thread post-menu-thread-${comment.cid}`}
|
||||||
style={{ display: rotatedStates[comment.cid] ? 'block' : 'none' }}>
|
style={{ display: rotatedStates[comment.cid] ? 'block' : 'none' }}>
|
||||||
<ul>
|
<ul>
|
||||||
{/* <li>Edit post</li> */}
|
<li onClick={() => handleOptionClick(comment.cid)}>Hide thread</li>
|
||||||
<li onClick={() => {handleOptionClick(comment.cid)}}>Hide thread</li>
|
{comment.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
<>
|
||||||
|
<li onClick={() => handleOptionClick(comment.cid)}>Edit post</li>
|
||||||
|
<li onClick={() => handleOptionClick(comment.cid)}>Delete post</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{isModerator ? (
|
||||||
|
<>
|
||||||
|
{comment.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
null
|
||||||
|
) : (
|
||||||
|
<li onClick={() => {
|
||||||
|
setModeratingCommentCid(comment.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(comment.cid);
|
||||||
|
setDeletePost(true);
|
||||||
|
}}>
|
||||||
|
Delete post
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
<li
|
||||||
|
onMouseOver={() => {setIsModToolsOpen(true)}}
|
||||||
|
onMouseLeave={() => {setIsModToolsOpen(false)}}
|
||||||
|
onClick={() => {
|
||||||
|
setModeratingCommentCid(comment.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(comment.cid);
|
||||||
|
}}>
|
||||||
|
Mod tools
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{(commentMediaInfo && (
|
{(commentMediaInfo && (
|
||||||
commentMediaInfo.type === 'image' ||
|
commentMediaInfo.type === 'image' ||
|
||||||
(commentMediaInfo.type === 'webpage' &&
|
(commentMediaInfo.type === 'webpage' &&
|
||||||
@@ -794,19 +755,19 @@ const Thread = () => {
|
|||||||
Image search »
|
Image search »
|
||||||
<ul className="dropdown-menu"
|
<ul className="dropdown-menu"
|
||||||
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
||||||
<li>
|
<li onClick={() => handleOptionClick(comment.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo.url}`}
|
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>Google</a>
|
>Google</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li onClick={() => handleOptionClick(comment.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://yandex.com/images/search?url=${commentMediaInfo.url}`}
|
href={`https://yandex.com/images/search?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>Yandex</a>
|
>Yandex</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li onClick={() => handleOptionClick(comment.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://saucenao.com/search.php?url=${commentMediaInfo.url}`}
|
href={`https://saucenao.com/search.php?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
@@ -816,42 +777,6 @@ const Thread = () => {
|
|||||||
</li>
|
</li>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
{isModerator ? (
|
|
||||||
<li
|
|
||||||
onMouseOver={() => {setIsModToolsOpen(true)}}
|
|
||||||
onMouseLeave={() => {setIsModToolsOpen(false)}}>
|
|
||||||
Mod tools »
|
|
||||||
<ul className="dropdown-menu"
|
|
||||||
style={{display: isModToolsOpen ? 'block': 'none'}}>
|
|
||||||
<li onClick={() => {
|
|
||||||
setModeratingCommentCid(comment.cid);
|
|
||||||
setIsModerationOpen(true);
|
|
||||||
handleOptionClick(comment.cid);
|
|
||||||
}}>
|
|
||||||
Open tools ↗
|
|
||||||
</li>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
comment.pinned ? 'Unpin' : 'Pin',
|
|
||||||
comment.cid,
|
|
||||||
{ pinned: comment.pinned, locked: comment.locked }
|
|
||||||
)}>
|
|
||||||
{comment.pinned ? 'Unpin' : 'Pin'}
|
|
||||||
</li>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
comment.locked ? 'Reopen' : 'Close',
|
|
||||||
comment.cid,
|
|
||||||
{ pinned: comment.pinned, locked: comment.locked }
|
|
||||||
)}>
|
|
||||||
{comment.locked ? 'Reopen' : 'Close'}
|
|
||||||
</li>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
'Delete', comment.cid
|
|
||||||
)}>
|
|
||||||
Delete
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
) : null}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="backlink-id" className="backlink">
|
<div id="backlink-id" className="backlink">
|
||||||
@@ -961,8 +886,39 @@ const Thread = () => {
|
|||||||
<div id="post-menu" className={`post-menu-reply post-menu-reply-${reply.cid}`}
|
<div id="post-menu" className={`post-menu-reply post-menu-reply-${reply.cid}`}
|
||||||
style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}>
|
style={{ display: rotatedStates[reply.cid] ? 'block' : 'none' }}>
|
||||||
<ul>
|
<ul>
|
||||||
{/* <li>Edit post</li> */}
|
|
||||||
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li>
|
<li onClick={() => handleOptionClick(reply.cid)}>Hide post</li>
|
||||||
|
{reply.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
<>
|
||||||
|
<li onClick={() => handleOptionClick(reply.cid)}>Edit post</li>
|
||||||
|
<li onClick={() => handleOptionClick(reply.cid)}>Delete post</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{isModerator ? (
|
||||||
|
<>
|
||||||
|
{reply.author.shortAddress === account.author.shortAddress ? (
|
||||||
|
null
|
||||||
|
) : (
|
||||||
|
<li onClick={() => {
|
||||||
|
setModeratingCommentCid(reply.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(reply.cid);
|
||||||
|
setDeletePost(true);
|
||||||
|
}}>
|
||||||
|
Delete post
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
<li
|
||||||
|
onMouseOver={() => {setIsModToolsOpen(true)}}
|
||||||
|
onMouseLeave={() => {setIsModToolsOpen(false)}}
|
||||||
|
onClick={() => {
|
||||||
|
setModeratingCommentCid(reply.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(reply.cid);
|
||||||
|
}}>
|
||||||
|
Mod tools
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
{(replyMediaInfo && (
|
{(replyMediaInfo && (
|
||||||
replyMediaInfo.type === 'image' ||
|
replyMediaInfo.type === 'image' ||
|
||||||
(replyMediaInfo.type === 'webpage' &&
|
(replyMediaInfo.type === 'webpage' &&
|
||||||
@@ -973,19 +929,19 @@ const Thread = () => {
|
|||||||
Image search »
|
Image search »
|
||||||
<ul className="dropdown-menu"
|
<ul className="dropdown-menu"
|
||||||
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
||||||
<li>
|
<li onClick={() => handleOptionClick(reply.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo.url}`}
|
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>Google</a>
|
>Google</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li onClick={() => handleOptionClick(reply.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://yandex.com/images/search?url=${commentMediaInfo.url}`}
|
href={`https://yandex.com/images/search?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
>Yandex</a>
|
>Yandex</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li onClick={() => handleOptionClick(reply.cid)}>
|
||||||
<a
|
<a
|
||||||
href={`https://saucenao.com/search.php?url=${commentMediaInfo.url}`}
|
href={`https://saucenao.com/search.php?url=${commentMediaInfo.url}`}
|
||||||
target="_blank" rel="noreferrer"
|
target="_blank" rel="noreferrer"
|
||||||
@@ -995,21 +951,6 @@ const Thread = () => {
|
|||||||
</li>
|
</li>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
{isModerator ? (
|
|
||||||
<li
|
|
||||||
onMouseOver={() => {setIsModToolsOpen(true)}}
|
|
||||||
onMouseLeave={() => {setIsModToolsOpen(false)}}>
|
|
||||||
Mod tools »
|
|
||||||
<ul className="dropdown-menu"
|
|
||||||
style={{display: isModToolsOpen ? 'block': 'none'}}>
|
|
||||||
<li onClick={() => handleModToolClick(
|
|
||||||
'Delete', reply.cid
|
|
||||||
)}>
|
|
||||||
Delete
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
) : null}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="backlink-id" className="backlink">
|
<div id="backlink-id" className="backlink">
|
||||||
|
|||||||
Reference in New Issue
Block a user