mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add post menu UI, mod logic, styling to catalog
This commit is contained in:
@@ -54,4 +54,44 @@ export const GlobalStyle = createGlobalStyle`
|
|||||||
max-height: 100% !important;
|
max-height: 100% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
position: absolute;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.3em;
|
||||||
|
list-style: none;
|
||||||
|
|
||||||
|
ul {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
padding: 2px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
left: 100%;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown:hover .dropdown-menu {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
@@ -78,3 +78,170 @@ export const Threads = styled.div`
|
|||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const PostMenuCatalog = styled.div`
|
||||||
|
.post-menu-catalog {
|
||||||
|
position: relative;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
li {
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
padding: 2px 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown:hover .dropdown-menu {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
${({ selectedStyle }) => {
|
||||||
|
switch (selectedStyle) {
|
||||||
|
case 'Yotsuba':
|
||||||
|
return `.highlighted {
|
||||||
|
background-color: #f0c0b0 !important;
|
||||||
|
border: 1px solid #d99f91 !important;
|
||||||
|
border-left: none !important;
|
||||||
|
border-top: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
border-right: 1px solid #d9bfb7;
|
||||||
|
border-bottom: 2px solid #d9bfb7;
|
||||||
|
|
||||||
|
li {
|
||||||
|
border: 1px solid #d9bfb7;
|
||||||
|
border-bottom: none;
|
||||||
|
background-color: #f0e0d6;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: #ffe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Yotsuba-B':
|
||||||
|
return `.highlighted {
|
||||||
|
background-color: #d6bad0 !important;
|
||||||
|
border: 1px solid #ba9dbf !important;
|
||||||
|
border-left: none !important;
|
||||||
|
border-top: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
border-right: 1px solid #b7c5d9;
|
||||||
|
border-bottom: 2px solid #b7c5d9;
|
||||||
|
|
||||||
|
li {
|
||||||
|
border: 1px solid #b7c5d9;
|
||||||
|
border-bottom: none;
|
||||||
|
background-color: #d6daf0;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: #eef2ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Futaba':
|
||||||
|
return `.highlighted {
|
||||||
|
background-color: #f0c0b0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
font-size: 13px !important;
|
||||||
|
border: 1px solid #d9bfb7;
|
||||||
|
border-bottom: none;
|
||||||
|
|
||||||
|
li {
|
||||||
|
background-color: #f0e0d6;
|
||||||
|
border-bottom: 1px solid #d9bfb7;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: #ffe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Burichan':
|
||||||
|
return `.highlighted {
|
||||||
|
background-color: #d6bad0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
font-size: 13px !important;
|
||||||
|
border: 1px solid #b7c5d9;
|
||||||
|
border-bottom: none;
|
||||||
|
|
||||||
|
li {
|
||||||
|
background-color: #d6daf0;
|
||||||
|
border-bottom: 1px solid #b7c5d9;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: #eef2ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Tomorrow':
|
||||||
|
return `.highlighted {
|
||||||
|
background-color: #1d1d21 !important;
|
||||||
|
border: 1px solid #111 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
border: 1px solid #000;
|
||||||
|
border-bottom: none;
|
||||||
|
|
||||||
|
li {
|
||||||
|
background-color: #282a2e;
|
||||||
|
border-bottom: 1px solid #000;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: #1d1f21;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
case 'Photon':
|
||||||
|
return `.highlighted {
|
||||||
|
background-color: #ccc !important;
|
||||||
|
border: 1px solid #ccc !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-menu-catalog {
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-bottom: none;
|
||||||
|
|
||||||
|
li {
|
||||||
|
background-color: #ddd;
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
|
||||||
|
:hover {
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
`;
|
||||||
@@ -1,16 +1,20 @@
|
|||||||
import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
import { Helmet } from 'react-helmet-async';
|
import { Helmet } from 'react-helmet-async';
|
||||||
import InfiniteScroll from 'react-infinite-scroller';
|
import InfiniteScroll from 'react-infinite-scroller';
|
||||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import { confirmAlert } from 'react-confirm-alert';
|
||||||
import { Tooltip } from 'react-tooltip';
|
import { Tooltip } from 'react-tooltip';
|
||||||
import { useFeed, usePublishComment, useSubplebbit, useSubscribe } from '@plebbit/plebbit-react-hooks';
|
import { useAccount, useFeed, usePublishComment, usePublishCommentEdit, useSubplebbit, useSubscribe } from '@plebbit/plebbit-react-hooks';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||||
import { Container, NavBar, Header, Break, PostForm, PostFormLink, PostFormTable } from '../styled/views/Board.styled';
|
import { Container, NavBar, Header, Break, PostForm, PostFormLink, PostFormTable, PostMenu, BoardForm } from '../styled/views/Board.styled';
|
||||||
import { Threads } from '../styled/views/Catalog.styled';
|
import { Threads, PostMenuCatalog } from '../styled/views/Catalog.styled';
|
||||||
import { TopBar, Footer } from '../styled/views/Thread.styled';
|
import { TopBar, Footer, AuthorDeleteAlert } from '../styled/views/Thread.styled';
|
||||||
import CatalogLoader from '../CatalogLoader';
|
import CatalogLoader from '../CatalogLoader';
|
||||||
|
import EditModal from '../modals/EditModal';
|
||||||
import ImageBanner from '../ImageBanner';
|
import ImageBanner from '../ImageBanner';
|
||||||
|
import ModerationModal from '../modals/ModerationModal';
|
||||||
import OfflineIndicator from '../OfflineIndicator';
|
import OfflineIndicator from '../OfflineIndicator';
|
||||||
import SettingsModal from '../modals/SettingsModal';
|
import SettingsModal from '../modals/SettingsModal';
|
||||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||||
@@ -28,8 +32,11 @@ const Catalog = () => {
|
|||||||
captchaResponse, setCaptchaResponse,
|
captchaResponse, setCaptchaResponse,
|
||||||
setChallengesArray,
|
setChallengesArray,
|
||||||
defaultSubplebbits,
|
defaultSubplebbits,
|
||||||
|
editedComment,
|
||||||
setIsCaptchaOpen,
|
setIsCaptchaOpen,
|
||||||
|
isModerationOpen, setIsModerationOpen,
|
||||||
isSettingsOpen, setIsSettingsOpen,
|
isSettingsOpen, setIsSettingsOpen,
|
||||||
|
setModeratingCommentCid,
|
||||||
setPendingComment,
|
setPendingComment,
|
||||||
setPendingCommentIndex,
|
setPendingCommentIndex,
|
||||||
setResolveCaptchaPromise,
|
setResolveCaptchaPromise,
|
||||||
@@ -45,25 +52,56 @@ const Catalog = () => {
|
|||||||
const subjectRef = useRef();
|
const subjectRef = useRef();
|
||||||
const commentRef = useRef();
|
const commentRef = useRef();
|
||||||
const linkRef = useRef();
|
const linkRef = useRef();
|
||||||
|
const threadMenuRefs = useRef({});
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [errorMessage, setErrorMessage] = useState(null);
|
const [errorMessage, setErrorMessage] = useState(null);
|
||||||
const [successMessage] = useState(null);
|
const [successMessage, setSuccessMessage] = useState(null);
|
||||||
useError(errorMessage, [errorMessage]);
|
useError(errorMessage, [errorMessage]);
|
||||||
useSuccess(successMessage, [successMessage]);
|
useSuccess(successMessage, [successMessage]);
|
||||||
|
|
||||||
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
|
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
|
||||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
|
const [isHoveringOnThread, setIsHoveringOnThread] = useState(false);
|
||||||
|
const [isModerator, setIsModerator] = useState(false);
|
||||||
|
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||||
|
const [originalCommentContent, setOriginalCommentContent] = useState(null);
|
||||||
|
const [triggerPublishCommentEdit, setTriggerPublishCommentEdit] = useState(false);
|
||||||
|
const [deletePost, setDeletePost] = useState(false);
|
||||||
|
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||||
|
const [commentCid, setCommentCid] = useState(null);
|
||||||
|
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
||||||
|
const [openMenuCid, setOpenMenuCid] = useState(null);
|
||||||
|
|
||||||
|
|
||||||
const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`${selectedAddress}`], sortType: 'new'});
|
const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`${selectedAddress}`], sortType: 'new'});
|
||||||
const { subplebbitAddress } = useParams();
|
const { subplebbitAddress } = useParams();
|
||||||
const subplebbit = useSubplebbit({subplebbitAddress: selectedAddress});
|
const subplebbit = useSubplebbit({subplebbitAddress: selectedAddress});
|
||||||
|
const account = useAccount();
|
||||||
|
|
||||||
const stateString = useStateString(subplebbit);
|
const stateString = useStateString(subplebbit);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (subplebbit.roles !== undefined) {
|
||||||
|
const role = subplebbit.roles[account?.author.address]?.role;
|
||||||
|
|
||||||
|
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||||
|
setIsModerator(true);
|
||||||
|
} else {
|
||||||
|
setIsModerator(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [account?.author.address, subplebbit.roles]);
|
||||||
|
|
||||||
|
|
||||||
|
const handleOptionClick = () => {
|
||||||
|
setOpenMenuCid(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedAddress(subplebbitAddress);
|
setSelectedAddress(subplebbitAddress);
|
||||||
}, [subplebbitAddress, setSelectedAddress]);
|
}, [subplebbitAddress, setSelectedAddress]);
|
||||||
@@ -85,6 +123,8 @@ const Catalog = () => {
|
|||||||
setErrorMessage(errorString);
|
setErrorMessage(errorString);
|
||||||
}
|
}
|
||||||
}, [errorString]);
|
}, [errorString]);
|
||||||
|
|
||||||
|
|
||||||
const { subscribed, subscribe, unsubscribe } = useSubscribe({subplebbitAddress: selectedAddress});
|
const { subscribed, subscribe, unsubscribe } = useSubscribe({subplebbitAddress: selectedAddress});
|
||||||
|
|
||||||
// temporary title from JSON, gets subplebbitAddress from URL
|
// temporary title from JSON, gets subplebbitAddress from URL
|
||||||
@@ -119,8 +159,12 @@ const Catalog = () => {
|
|||||||
|
|
||||||
const onChallengeVerification = (challengeVerification) => {
|
const onChallengeVerification = (challengeVerification) => {
|
||||||
if (challengeVerification.challengeSuccess === true) {
|
if (challengeVerification.challengeSuccess === true) {
|
||||||
navigate(`/p/${selectedAddress}/c/${challengeVerification.publication?.cid}`);
|
if (challengeVerification.publication?.cid !== undefined) {
|
||||||
console.log('challenge success');
|
navigate(`/p/${subplebbitAddress}/c/${challengeVerification.publication?.cid}`);
|
||||||
|
console.log('challenge success');
|
||||||
|
} else {
|
||||||
|
setSuccessMessage('Challenge Success');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (challengeVerification.challengeSuccess === false) {
|
else if (challengeVerification.challengeSuccess === false) {
|
||||||
setErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
|
setErrorMessage('Challenge Failed', {reason: challengeVerification.reason, errors: challengeVerification.errors});
|
||||||
@@ -254,6 +298,94 @@ const Catalog = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const [publishCommentEditOptions, setPublishCommentEditOptions] = useState({
|
||||||
|
commentCid: commentCid,
|
||||||
|
content: editedComment || undefined,
|
||||||
|
subplebbitAddress: selectedAddress || subplebbitAddress,
|
||||||
|
onChallenge,
|
||||||
|
onChallengeVerification,
|
||||||
|
onError: (error) => {
|
||||||
|
setErrorMessage(error);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const {error, publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (error) {
|
||||||
|
setErrorMessage(error);
|
||||||
|
}
|
||||||
|
}, [error]);
|
||||||
|
|
||||||
|
|
||||||
|
const handleAuthorDeleteClick = (commentCid) => {
|
||||||
|
handleOptionClick(commentCid);
|
||||||
|
|
||||||
|
confirmAlert({
|
||||||
|
customUI: ({ onClose }) => {
|
||||||
|
return (
|
||||||
|
<AuthorDeleteAlert selectedStyle={selectedStyle}>
|
||||||
|
<div className='author-delete-alert'>
|
||||||
|
<p>Are you sure you want to delete this post?</p>
|
||||||
|
<div className="author-delete-buttons">
|
||||||
|
<button onClick={onClose}>No</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setCommentCid(commentCid);
|
||||||
|
setPublishCommentEditOptions(prevOptions => ({
|
||||||
|
...prevOptions,
|
||||||
|
deleted: true,
|
||||||
|
}));
|
||||||
|
setTriggerPublishCommentEdit(true);
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Yes
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</AuthorDeleteAlert>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const handleAuthorEditClick = (comment) => {
|
||||||
|
handleOptionClick(comment.cid);
|
||||||
|
setCommentCid(comment.cid);
|
||||||
|
setOriginalCommentContent(comment.content);
|
||||||
|
setIsEditModalOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setPublishCommentEditOptions((prevOptions) => ({
|
||||||
|
...prevOptions,
|
||||||
|
commentCid: commentCid,
|
||||||
|
content: editedComment || undefined,
|
||||||
|
}));
|
||||||
|
}, [commentCid, editedComment]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (editedComment !== '') {
|
||||||
|
setTriggerPublishCommentEdit(true);
|
||||||
|
}
|
||||||
|
}, [editedComment]);
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
@@ -295,6 +427,16 @@ const Catalog = () => {
|
|||||||
selectedStyle={selectedStyle}
|
selectedStyle={selectedStyle}
|
||||||
isOpen={isSettingsOpen}
|
isOpen={isSettingsOpen}
|
||||||
closeModal={() => setIsSettingsOpen(false)} />
|
closeModal={() => setIsSettingsOpen(false)} />
|
||||||
|
<ModerationModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isModerationOpen}
|
||||||
|
closeModal={() => setIsModerationOpen(false)}
|
||||||
|
deletePost={deletePost} />
|
||||||
|
<EditModal
|
||||||
|
selectedStyle={selectedStyle}
|
||||||
|
isOpen={isEditModalOpen}
|
||||||
|
closeModal={() => setIsEditModalOpen(false)}
|
||||||
|
originalCommentContent={originalCommentContent} />
|
||||||
<NavBar selectedStyle={selectedStyle}>
|
<NavBar selectedStyle={selectedStyle}>
|
||||||
<>
|
<>
|
||||||
<span className="boardList">
|
<span className="boardList">
|
||||||
@@ -484,45 +626,44 @@ const Catalog = () => {
|
|||||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||||
return (
|
return (
|
||||||
<Link style={{all: "unset", cursor: "pointer"}} key={`link-${index}`} to={`/p/${selectedAddress}/c/${thread.cid}`}
|
<div key={`thread-${index}`} className="thread"
|
||||||
onClick={() => setSelectedThread(thread.cid)}>
|
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||||
<div key={`thread-${index}`} className="thread">
|
onMouseLeave={() => {setIsHoveringOnThread('')}}>
|
||||||
{commentMediaInfo?.url ? (
|
{commentMediaInfo?.url ? (
|
||||||
<Fragment key="f-catalog">
|
<Link style={{all: "unset", cursor: "pointer"}} key={`link-${index}`} to={`/p/${selectedAddress}/c/${thread.cid}`}
|
||||||
{commentMediaInfo?.type === "webpage" ? (
|
onClick={() => setSelectedThread(thread.cid)}>
|
||||||
thread.thumbnailUrl ? (
|
{commentMediaInfo?.type === "webpage" ? (
|
||||||
<img className="card" key={`img-${index}`}
|
thread.thumbnailUrl ? (
|
||||||
src={commentMediaInfo.thumbnail} alt={commentMediaInfo.type}
|
<img className="card" key={`img-${index}`}
|
||||||
onError={(e) => {
|
src={commentMediaInfo.thumbnail} alt={commentMediaInfo.type}
|
||||||
e.target.src = fallbackImgUrl
|
onError={(e) => {
|
||||||
e.target.onerror = null;
|
e.target.src = fallbackImgUrl
|
||||||
}} />
|
e.target.onerror = null;
|
||||||
) : null
|
}} />
|
||||||
) : null}
|
) : null
|
||||||
{commentMediaInfo?.type === "image" ? (
|
) : null}
|
||||||
<img className="card" key={`img-${index}`}
|
{commentMediaInfo?.type === "image" ? (
|
||||||
src={commentMediaInfo.url} alt={commentMediaInfo.type}
|
<img className="card" key={`img-${index}`}
|
||||||
onError={(e) => {
|
src={commentMediaInfo.url} alt={commentMediaInfo.type}
|
||||||
e.target.src = fallbackImgUrl
|
onError={(e) => {
|
||||||
e.target.onerror = null;}} />
|
e.target.src = fallbackImgUrl
|
||||||
) : null}
|
e.target.onerror = null;}} />
|
||||||
{commentMediaInfo?.type === "video" ? (
|
) : null}
|
||||||
|
{commentMediaInfo?.type === "video" ? (
|
||||||
<video className="card" key={`fti-${index}`}
|
<video className="card" key={`fti-${index}`}
|
||||||
src={commentMediaInfo.url}
|
src={commentMediaInfo.url}
|
||||||
alt={commentMediaInfo.type}
|
alt={commentMediaInfo.type}
|
||||||
style={{ pointerEvents: "none" }}
|
|
||||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||||
) : null}
|
) : null}
|
||||||
{commentMediaInfo?.type === "audio" ? (
|
{commentMediaInfo?.type === "audio" ? (
|
||||||
<audio className="card" controls
|
<audio className="card" controls
|
||||||
key={`fti-${index}`}
|
key={`fti-${index}`}
|
||||||
src={commentMediaInfo.url}
|
src={commentMediaInfo.url}
|
||||||
alt={commentMediaInfo.type}
|
alt={commentMediaInfo.type}
|
||||||
style={{ pointerEvents: "none" }}
|
|
||||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||||
) : null}
|
) : null}
|
||||||
</Fragment>
|
</Link>
|
||||||
) : null}
|
) : null}
|
||||||
<div key={`ti-${index}`} className="thread-icons" >
|
<div key={`ti-${index}`} className="thread-icons" >
|
||||||
{thread.pinned ? (
|
{thread.pinned ? (
|
||||||
<span key={`si-${index}`} className="thread-icon sticky-icon" title="Sticky" />
|
<span key={`si-${index}`} className="thread-icon sticky-icon" title="Sticky" />
|
||||||
@@ -531,16 +672,115 @@ const Catalog = () => {
|
|||||||
<span key={`li-${index}`} className="thread-icon closed-icon" title="Closed" />
|
<span key={`li-${index}`} className="thread-icon closed-icon" title="Closed" />
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
<BoardForm selectedStyle={selectedStyle}
|
||||||
R:
|
style={{ all: "unset"}}>
|
||||||
<b key={`b-${index}`}>{thread.replyCount}</b>
|
<div key={`meta-${index}`} className="meta" title="(R)eplies / (I)mage Replies" >
|
||||||
</div>
|
R:
|
||||||
<div key={`t-${index}`} className="teaser">
|
<b key={`b-${index}`}>{thread.replyCount}</b>
|
||||||
|
<PostMenu
|
||||||
|
style={{ display: isHoveringOnThread === thread.cid ? 'inline-block' : 'none',
|
||||||
|
position: 'absolute', lineHeight: '1em', marginTop: '-1px', outline: 'none',
|
||||||
|
zIndex: '999'}}
|
||||||
|
key={`pmb-${index}`}
|
||||||
|
title="Post menu"
|
||||||
|
ref={el => threadMenuRefs.current[thread.cid] = el}
|
||||||
|
className='post-menu-button'
|
||||||
|
id='post-menu-button-catalog'
|
||||||
|
rotated={openMenuCid === thread.cid}
|
||||||
|
onClick={() => {
|
||||||
|
const rect = threadMenuRefs.current[thread.cid].getBoundingClientRect();
|
||||||
|
setMenuPosition({top: rect.top + window.scrollY, left: rect.left});
|
||||||
|
setOpenMenuCid(prevCid => (prevCid === thread.cid ? null : thread.cid));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
▶
|
||||||
|
</PostMenu>
|
||||||
|
</div>
|
||||||
|
{createPortal(
|
||||||
|
<PostMenuCatalog selectedStyle={selectedStyle}
|
||||||
|
style={{position: "absolute",
|
||||||
|
top: menuPosition.top + 7,
|
||||||
|
left: menuPosition.left}}>
|
||||||
|
<div className={`post-menu-thread post-menu-thread-${thread.cid}`}
|
||||||
|
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
|
||||||
|
>
|
||||||
|
<ul className="post-menu-catalog">
|
||||||
|
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li>
|
||||||
|
{thread.author.shortAddress === account?.author.shortAddress ? (
|
||||||
|
<>
|
||||||
|
<li onClick={() => handleAuthorEditClick(thread)}>Edit post</li>
|
||||||
|
<li onClick={() => handleAuthorDeleteClick(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
|
||||||
|
onClick={() => {
|
||||||
|
setModeratingCommentCid(thread.cid)
|
||||||
|
setIsModerationOpen(true);
|
||||||
|
handleOptionClick(thread.cid);
|
||||||
|
}}>
|
||||||
|
Mod tools
|
||||||
|
</li>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{(commentMediaInfo && (
|
||||||
|
commentMediaInfo.type === 'image' ||
|
||||||
|
(commentMediaInfo.type === 'webpage' &&
|
||||||
|
commentMediaInfo.thumbnail))) ? (
|
||||||
|
<li
|
||||||
|
onMouseOver={() => {setIsImageSearchOpen(true)}}
|
||||||
|
onMouseLeave={() => {setIsImageSearchOpen(false)}}>
|
||||||
|
Image search »
|
||||||
|
<ul className="dropdown-menu"
|
||||||
|
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
||||||
|
<li onClick={() => handleOptionClick(thread.cid)}>
|
||||||
|
<a
|
||||||
|
href={`https://lens.google.com/uploadbyurl?url=${commentMediaInfo.url}`}
|
||||||
|
target="_blank" rel="noreferrer"
|
||||||
|
>Google</a>
|
||||||
|
</li>
|
||||||
|
<li onClick={() => handleOptionClick(thread.cid)}>
|
||||||
|
<a
|
||||||
|
href={`https://yandex.com/images/search?url=${commentMediaInfo.url}`}
|
||||||
|
target="_blank" rel="noreferrer"
|
||||||
|
>Yandex</a>
|
||||||
|
</li>
|
||||||
|
<li onClick={() => handleOptionClick(thread.cid)}>
|
||||||
|
<a
|
||||||
|
href={`https://saucenao.com/search.php?url=${commentMediaInfo.url}`}
|
||||||
|
target="_blank" rel="noreferrer"
|
||||||
|
>SauceNAO</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</PostMenuCatalog>, document.body
|
||||||
|
)}
|
||||||
|
</BoardForm>
|
||||||
|
<Link style={{all: "unset", cursor: "pointer"}} key={`link2-${index}`} to={`/p/${selectedAddress}/c/${thread.cid}`}
|
||||||
|
onClick={() => setSelectedThread(thread.cid)}>
|
||||||
|
<div key={`t-${index}`} className="teaser">
|
||||||
<b key={`b2-${index}`}>{thread.title ? `${thread.title}` : null}</b>
|
<b key={`b2-${index}`}>{thread.title ? `${thread.title}` : null}</b>
|
||||||
{thread.content ? `: ${thread.content}` : null}
|
{thread.content ? `: ${thread.content}` : null}
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
|
||||||
)})}
|
)})}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
) : (<CatalogLoader />)
|
) : (<CatalogLoader />)
|
||||||
|
|||||||
Reference in New Issue
Block a user