mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
add refresh button
This commit is contained in:
committed by
plebeius.eth
parent
be80c0398e
commit
9057256571
+401
-386
@@ -1,32 +1,32 @@
|
||||
import { useAccount, useFeed, usePublishCommentEdit, useSubplebbits } from '@plebbit/plebbit-react-hooks';
|
||||
import InfiniteScroll from 'react-infinite-scroller';
|
||||
import { debounce } from 'lodash';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { confirmAlert } from 'react-confirm-alert';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import { Link, useNavigate} from 'react-router-dom';
|
||||
import { confirmAlert } from 'react-confirm-alert';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Tooltip } from 'react-tooltip';
|
||||
import { VirtuosoGrid } from 'react-virtuoso';
|
||||
import { useAccount, useFeed, usePublishCommentEdit, useSubplebbits } from '@plebbit/plebbit-react-hooks';
|
||||
import { debounce } from 'lodash';
|
||||
import { Container, NavBar, Header, Break, PostMenu, BoardForm } from '../styled/views/Board.styled';
|
||||
import { Threads, PostMenuCatalog, GridContainer } from '../styled/views/Catalog.styled';
|
||||
import { TopBar, Footer, AuthorDeleteAlert } from '../styled/views/Thread.styled';
|
||||
import CatalogLoader from '../CatalogLoader';
|
||||
import EditModal from '../modals/EditModal';
|
||||
import ImageBanner from '../ImageBanner';
|
||||
import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import CreateBoardModal from '../modals/CreateBoardModal';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import packageJson from '../../../package.json';
|
||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||
import useError from '../../hooks/useError';
|
||||
import useFeedStateString from '../../hooks/useFeedStateString';
|
||||
import useSuccess from '../../hooks/useSuccess';
|
||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||
import packageJson from '../../../package.json'
|
||||
const {version} = packageJson
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import CatalogLoader from '../CatalogLoader';
|
||||
import ImageBanner from '../ImageBanner';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import CreateBoardModal from '../modals/CreateBoardModal';
|
||||
import EditModal from '../modals/EditModal';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import { BoardForm, Break, Container, Header, NavBar, PostMenu } from '../styled/views/Board.styled';
|
||||
import { PostMenuCatalog, Threads } from '../styled/views/Catalog.styled';
|
||||
import { AuthorDeleteAlert, Footer, TopBar } from '../styled/views/Thread.styled';
|
||||
const { version } = packageJson
|
||||
|
||||
|
||||
const AllCatalog = () => {
|
||||
@@ -47,7 +47,7 @@ const AllCatalog = () => {
|
||||
setSelectedThread,
|
||||
setSelectedTitle,
|
||||
} = useGeneralStore(state => state);
|
||||
|
||||
|
||||
|
||||
const threadMenuRefs = useRef({});
|
||||
const postMenuRef = useRef(null);
|
||||
@@ -57,7 +57,7 @@ const AllCatalog = () => {
|
||||
const navigate = useNavigate();
|
||||
const [, setNewErrorMessage] = useError();
|
||||
const [, setNewSuccessMessage] = useSuccess();
|
||||
|
||||
|
||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||
const [visible, setVisible] = useState(true);
|
||||
const [isHoveringOnThread, setIsHoveringOnThread] = useState(false);
|
||||
@@ -68,14 +68,14 @@ const AllCatalog = () => {
|
||||
const [deletePost, setDeletePost] = useState(false);
|
||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||
const [commentCid, setCommentCid] = useState(null);
|
||||
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||
const [openMenuCid, setOpenMenuCid] = useState(null);
|
||||
const [moderatorPermissions, setModeratorPermissions] = useState({});
|
||||
const [isCreateBoardOpen, setIsCreateBoardOpen] = useState(false);
|
||||
|
||||
const addresses = defaultSubplebbits.map(subplebbit => subplebbit.address);
|
||||
const { feed, loadMore } = useFeed({subplebbitAddresses: addresses, sortType: 'active'});
|
||||
const {subplebbits} = useSubplebbits({subplebbitAddresses: addresses, sortType: 'active'});
|
||||
const { feed, hasMore, loadMore } = useFeed({ subplebbitAddresses: addresses, sortType: 'active' });
|
||||
const { subplebbits } = useSubplebbits({ subplebbitAddresses: addresses, sortType: 'active' });
|
||||
const [selectedFeed, setSelectedFeed] = useState(feed.sort((a, b) => b.timestamp - a.timestamp));
|
||||
|
||||
const stateString = useFeedStateString(subplebbits);
|
||||
@@ -83,13 +83,13 @@ const AllCatalog = () => {
|
||||
|
||||
useEffect(() => {
|
||||
let permissions = {};
|
||||
|
||||
|
||||
selectedFeed.forEach(thread => {
|
||||
const subplebbit = subplebbits.find(s => s && s.address === thread.subplebbitAddress);
|
||||
|
||||
if (subplebbit && subplebbit.roles) {
|
||||
|
||||
if (subplebbit && subplebbit.roles) {
|
||||
const role = subplebbit.roles[account?.author.address]?.role;
|
||||
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
permissions[thread.subplebbitAddress] = true;
|
||||
} else {
|
||||
@@ -97,9 +97,9 @@ const AllCatalog = () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setModeratorPermissions(permissions);
|
||||
}, [account?.author.address, selectedFeed, subplebbits]);
|
||||
}, [account?.author.address, selectedFeed, subplebbits]);
|
||||
|
||||
|
||||
const handleOptionClick = () => {
|
||||
@@ -120,7 +120,7 @@ const AllCatalog = () => {
|
||||
} else {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
}
|
||||
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
};
|
||||
@@ -134,24 +134,23 @@ const AllCatalog = () => {
|
||||
setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10);
|
||||
setPrevScrollPos(currentScrollPos);
|
||||
}, 50);
|
||||
|
||||
|
||||
window.addEventListener('scroll', debouncedHandleScroll);
|
||||
|
||||
|
||||
return () => window.removeEventListener('scroll', debouncedHandleScroll);
|
||||
}, [prevScrollPos, visible]);
|
||||
|
||||
|
||||
const tryLoadMore = async () => {
|
||||
try {loadMore()}
|
||||
catch (e)
|
||||
{await new Promise(resolve => setTimeout(resolve, 1000))}
|
||||
try { loadMore() }
|
||||
catch (e) { await new Promise(resolve => setTimeout(resolve, 1000)) }
|
||||
};
|
||||
|
||||
|
||||
const onChallengeVerification = (challengeVerification) => {
|
||||
if (challengeVerification.challengeSuccess === true) {
|
||||
setNewSuccessMessage('Challenge Success');
|
||||
}
|
||||
setNewSuccessMessage('Challenge Success');
|
||||
}
|
||||
else if (challengeVerification.challengeSuccess === false) {
|
||||
setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`);
|
||||
console.log('challenge failed', challengeVerification);
|
||||
@@ -175,16 +174,16 @@ const AllCatalog = () => {
|
||||
|
||||
const getChallengeAnswersFromUser = async (challenges) => {
|
||||
setChallengesArray(challenges);
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const imageString = challenges?.challenges[0].challenge;
|
||||
const imageSource = `data:image/png;base64,${imageString}`;
|
||||
const challengeImg = new Image();
|
||||
challengeImg.src = imageSource;
|
||||
|
||||
|
||||
challengeImg.onload = () => {
|
||||
setIsCaptchaOpen(true);
|
||||
|
||||
|
||||
const handleKeyDown = async (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
const currentCaptchaResponse = useGeneralStore.getState().captchaResponse;
|
||||
@@ -200,7 +199,7 @@ const AllCatalog = () => {
|
||||
|
||||
setResolveCaptchaPromise(resolve);
|
||||
};
|
||||
|
||||
|
||||
challengeImg.onerror = () => {
|
||||
reject(setNewErrorMessage('Could not load challenges'));
|
||||
};
|
||||
@@ -217,8 +216,8 @@ const AllCatalog = () => {
|
||||
setNewErrorMessage(error.message); console.log(error);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
|
||||
|
||||
|
||||
@@ -265,8 +264,8 @@ const AllCatalog = () => {
|
||||
setOriginalCommentContent(comment.content);
|
||||
setIsEditModalOpen(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setPublishCommentEditOptions((prevOptions) => ({
|
||||
...prevOptions,
|
||||
@@ -282,7 +281,7 @@ const AllCatalog = () => {
|
||||
}
|
||||
}, [editedComment, setIsAuthorEdit]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
let isActive = true;
|
||||
if (publishCommentEditOptions && triggerPublishCommentEdit) {
|
||||
@@ -329,69 +328,69 @@ const AllCatalog = () => {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>p/All - Catalog - plebchan</title>
|
||||
<title>p/All - Catalog - plebchan</title>
|
||||
</Helmet>
|
||||
<Container>
|
||||
<CreateBoardModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isCreateBoardOpen}
|
||||
closeModal={() => setIsCreateBoardOpen(false)} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isCreateBoardOpen}
|
||||
closeModal={() => setIsCreateBoardOpen(false)} />
|
||||
<SettingsModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isSettingsOpen}
|
||||
closeModal={() => setIsSettingsOpen(false)} />
|
||||
<ModerationModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isModerationOpen}
|
||||
closeModal={() => {setIsModerationOpen(false); setDeletePost(false)}}
|
||||
deletePost={deletePost} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isSettingsOpen}
|
||||
closeModal={() => setIsSettingsOpen(false)} />
|
||||
<ModerationModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isModerationOpen}
|
||||
closeModal={() => { setIsModerationOpen(false); setDeletePost(false) }}
|
||||
deletePost={deletePost} />
|
||||
<EditModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isEditModalOpen}
|
||||
closeModal={() => setIsEditModalOpen(false)}
|
||||
originalCommentContent={originalCommentContent} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isEditModalOpen}
|
||||
closeModal={() => setIsEditModalOpen(false)}
|
||||
originalCommentContent={originalCommentContent} />
|
||||
<NavBar selectedStyle={selectedStyle}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/all`} onClick={() => window.scrollTo(0, 0)}>All</Link>
|
||||
/
|
||||
/
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
]
|
||||
[
|
||||
<Link to="/">Home</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
]
|
||||
[
|
||||
<Link to="/">Home</Link>
|
||||
]
|
||||
</span >
|
||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||
<div className="nav-container">
|
||||
<div className="board-select">
|
||||
@@ -401,27 +400,27 @@ const AllCatalog = () => {
|
||||
<option value="all">All</option>
|
||||
<option value="subscriptions">Subscriptions</option>
|
||||
{defaultSubplebbits.map(subplebbit => (
|
||||
<option key={`option-${subplebbit.address}`} value={subplebbit.address}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</option>
|
||||
))}
|
||||
</select>
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
<option key={`option-${subplebbit.address}`} value={subplebbit.address}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</option>
|
||||
))}
|
||||
</select>
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
}>Create Board</span>
|
||||
</div>
|
||||
<div className="page-jump">
|
||||
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
|
||||
<Link to="/" onClick={() => {handleStyleChange({target: {value: "Yotsuba"}}); window.scrollTo(0, 0);}}>Home</Link>
|
||||
<Link to="/" onClick={() => { handleStyleChange({ target: { value: "Yotsuba" } }); window.scrollTo(0, 0); }}>Home</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="separator-mobile"> </div>
|
||||
<div id="separator-mobile"> </div>
|
||||
</>
|
||||
</NavBar>
|
||||
</NavBar >
|
||||
<Header selectedStyle={selectedStyle}>
|
||||
<>
|
||||
<div className="banner">
|
||||
@@ -436,7 +435,7 @@ const AllCatalog = () => {
|
||||
<hr />
|
||||
<span className="style-changer">
|
||||
Style:
|
||||
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
@@ -451,15 +450,27 @@ const AllCatalog = () => {
|
||||
<Link to={`/p/all`}>Return</Link>
|
||||
]
|
||||
</div>
|
||||
<span className="return-button catalog-button" id="refresh-button-desktop">
|
||||
[
|
||||
<span id="button" style={{ cursor: 'pointer' }} onClick={() => window.location.reload()}
|
||||
onMouseOver={(event) => event.target.style.cursor = 'pointer'}
|
||||
onTouchStart={() => window.location.reload()}>Refresh</span>
|
||||
]
|
||||
</span>
|
||||
<div id="return-button-mobile">
|
||||
<span className="btn-wrap-catalog btn-wrap">
|
||||
<Link to={`/p/all`}>Return</Link>
|
||||
</span>
|
||||
</div>
|
||||
<div id="refresh-button-mobile">
|
||||
<span className="btn-wrap-catalog btn-wrap">
|
||||
<Link to={`/p/all/catalog`}>Refresh</Link>
|
||||
</span>
|
||||
</div>
|
||||
{subplebbits.state === "succeeded" ? (
|
||||
null
|
||||
) : (
|
||||
<div id="stats" style={{float: "right", marginTop: "5px"}}>
|
||||
<div id="stats" style={{ float: "right", marginTop: "5px" }}>
|
||||
<span className={stateString ? "ellipsis" : ""}>{stateString}</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -467,276 +478,280 @@ const AllCatalog = () => {
|
||||
</TopBar>
|
||||
<Tooltip id="tooltip" className="tooltip" />
|
||||
<Threads selectedStyle={selectedStyle}>
|
||||
{feed.length > 1 ? (
|
||||
<VirtuosoGrid
|
||||
style={{width: '100%', height: '100%'}}
|
||||
data={feed}
|
||||
increaseViewportBy={{bottom: 600, top: 600}}
|
||||
itemContent={(index) => {
|
||||
const thread = feed[index];
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const linkCount = countLinks(thread);
|
||||
return (
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||
onMouseLeave={() => {setIsHoveringOnThread('')}}>
|
||||
{commentMediaInfo?.url ? (
|
||||
<Link style={{all: "unset", cursor: "pointer"}} key={`link-${index}`} to={`/p/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
{commentMediaInfo?.type === "webpage" ? (
|
||||
thread.thumbnailUrl ? (
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.thumbnail} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;
|
||||
}} />
|
||||
) : null
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "image" ? (
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.url} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;}} />
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "video" ? (
|
||||
<video className="card" key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "audio" ? (
|
||||
<audio className="card" controls
|
||||
key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
) : null}
|
||||
</Link>
|
||||
) : null}
|
||||
<div key={`ti-${index}`} className="thread-icons" >
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
commentMediaInfo.type === 'video' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon"
|
||||
tooltipPlace="top" />
|
||||
) : (
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon-no-link"
|
||||
tooltipPlace="top" />
|
||||
)}
|
||||
</div>
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset"}}>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
{linkCount > 0 ? (
|
||||
<>
|
||||
/
|
||||
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||
</>
|
||||
) : null}
|
||||
<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;
|
||||
postMenuRef.current = el;
|
||||
}}
|
||||
className='post-menu-button'
|
||||
id='post-menu-button-catalog'
|
||||
rotated={openMenuCid === thread.cid}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
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}
|
||||
ref={el => {postMenuCatalogRef.current = el}}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
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>
|
||||
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
|
||||
<>
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
<>
|
||||
<li onClick={() => handleAuthorEditClick(thread)}>Edit post</li>
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
null
|
||||
) : (
|
||||
<li onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
setDeletePost(true);
|
||||
}}>
|
||||
Delete post
|
||||
</li>
|
||||
)}
|
||||
<li
|
||||
onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
}}>
|
||||
Mod tools
|
||||
</li>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
)}</VerifiedAuthor>
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<li
|
||||
onMouseOver={() => {setIsImageSearchOpen(true)}}
|
||||
onMouseLeave={() => {setIsImageSearchOpen(false)}}>
|
||||
Image search »
|
||||
<ul className="dropdown-menu post-menu-catalog"
|
||||
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/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
<div key={`t-${index}`} className="teaser">
|
||||
<b key={`b2-${index}`}>{thread.title ? `${thread.title}` : null}</b>
|
||||
{thread.content ? `: ${thread.content}` : null}
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
endReached={tryLoadMore}
|
||||
useWindowScroll={true}
|
||||
components={{List: GridContainer}}
|
||||
/>
|
||||
) : (<CatalogLoader />)}
|
||||
</Threads>
|
||||
<Footer selectedStyle={selectedStyle}>
|
||||
<Break id="break" selectedStyle={selectedStyle} style={{
|
||||
marginTop: "-36px",
|
||||
width: "100%",
|
||||
}} />
|
||||
<Break selectedStyle={selectedStyle} style={{
|
||||
width: "100%",
|
||||
}} />
|
||||
<span className="style-changer" style={{
|
||||
float: "right",
|
||||
marginTop: "2px",
|
||||
}}>
|
||||
Style:
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
<option value="Futaba">Futaba</option>
|
||||
<option value="Burichan">Burichan</option>
|
||||
<option value="Tomorrow">Tomorrow</option>
|
||||
<option value="Photon">Photon</option>
|
||||
</select>
|
||||
</span>
|
||||
<NavBar selectedStyle={selectedStyle} style={{
|
||||
marginTop: "42px",
|
||||
}}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/all`} onClick={() => window.scrollTo(0, 0)}>All</Link>
|
||||
/
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => handleClickTitle(subplebbit.title, subplebbit.address)}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
{feed ? (
|
||||
<InfiniteScroll
|
||||
pageStart={0}
|
||||
loadMore={tryLoadMore}
|
||||
hasMore={hasMore}
|
||||
>
|
||||
{feed.map((thread, index) => {
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const linkCount = countLinks(thread);
|
||||
return (
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => { setIsHoveringOnThread(thread.cid) }}
|
||||
onMouseLeave={() => { setIsHoveringOnThread('') }}>
|
||||
{commentMediaInfo?.url ? (
|
||||
<Link style={{ all: "unset", cursor: "pointer" }} key={`link-${index}`} to={`/p/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
{commentMediaInfo?.type === "webpage" ? (
|
||||
thread.thumbnailUrl ? (
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.thumbnail} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;
|
||||
}} />
|
||||
) : null
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "image" ? (
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.url} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;
|
||||
}} />
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "video" ? (
|
||||
<video className="card" key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "audio" ? (
|
||||
<audio className="card" controls
|
||||
key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
) : null}
|
||||
</Link>
|
||||
) : null}
|
||||
<div key={`ti-${index}`} className="thread-icons" >
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
commentMediaInfo.type === 'video' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon"
|
||||
tooltipPlace="top" />
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon-no-link"
|
||||
tooltipPlace="top" />
|
||||
)}
|
||||
</div>
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset" }}>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
{linkCount > 0 ? (
|
||||
<>
|
||||
/
|
||||
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||
</>
|
||||
) : null}
|
||||
<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;
|
||||
postMenuRef.current = el;
|
||||
}}
|
||||
className='post-menu-button'
|
||||
id='post-menu-button-catalog'
|
||||
rotated={openMenuCid === thread.cid}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
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}
|
||||
ref={el => { postMenuCatalogRef.current = el }}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
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>
|
||||
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
|
||||
<>
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
<>
|
||||
<li onClick={() => handleAuthorEditClick(thread)}>Edit post</li>
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
</>
|
||||
) : null}
|
||||
{isModerator ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
null
|
||||
) : (
|
||||
<li onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
setDeletePost(true);
|
||||
}}>
|
||||
Delete post
|
||||
</li>
|
||||
)}
|
||||
<li
|
||||
onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
}}>
|
||||
Mod tools
|
||||
</li>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
)}</VerifiedAuthor>
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<li
|
||||
onMouseOver={() => { setIsImageSearchOpen(true) }}
|
||||
onMouseLeave={() => { setIsImageSearchOpen(false) }}>
|
||||
Image search »
|
||||
<ul className="dropdown-menu post-menu-catalog"
|
||||
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/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
<div key={`t-${index}`} className="teaser">
|
||||
<b key={`b2-${index}`}>{thread.title ? `${thread.title}` : null}</b>
|
||||
{thread.content ? `: ${thread.content}` : null}
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
) : (
|
||||
<CatalogLoader />
|
||||
)}
|
||||
</Threads >
|
||||
<Footer selectedStyle={selectedStyle}>
|
||||
<Break id="break" selectedStyle={selectedStyle} style={{
|
||||
marginTop: "-36px",
|
||||
width: "100%",
|
||||
}} />
|
||||
<Break selectedStyle={selectedStyle} style={{
|
||||
width: "100%",
|
||||
}} />
|
||||
<span className="style-changer" style={{
|
||||
float: "right",
|
||||
marginTop: "2px",
|
||||
}}>
|
||||
Style:
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
<option value="Futaba">Futaba</option>
|
||||
<option value="Burichan">Burichan</option>
|
||||
<option value="Tomorrow">Tomorrow</option>
|
||||
<option value="Photon">Photon</option>
|
||||
</select>
|
||||
</span>
|
||||
<NavBar selectedStyle={selectedStyle} style={{
|
||||
marginTop: "42px",
|
||||
}}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/all`} onClick={() => window.scrollTo(0, 0)}>All</Link>
|
||||
/
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => handleClickTitle(subplebbit.title, subplebbit.address)}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
||||
)}>Home</Link>
|
||||
]
|
||||
</span>
|
||||
[
|
||||
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
]
|
||||
[
|
||||
<Link to="/" onClick={() => handleStyleChange({ target: { value: "Yotsuba" } }
|
||||
)}>Home</Link>
|
||||
]
|
||||
</span >
|
||||
</>
|
||||
</NavBar>
|
||||
</NavBar >
|
||||
<div id="version">
|
||||
plebchan v{version}. GPL-2.0
|
||||
</div>
|
||||
@@ -748,16 +763,16 @@ const AllCatalog = () => {
|
||||
marginTop: "5px",
|
||||
marginBottom: "15px",
|
||||
}}>
|
||||
<a style={{textDecoration: 'underline'}} href="https://plebbit.com" target="_blank" rel="noopener noreferrer">About</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://github.com/plebbit/plebchan/releases/latest" target="_blank" rel="noopener noreferrer">App</a>
|
||||
<a style={{ textDecoration: 'underline' }} href="https://plebbit.com" target="_blank" rel="noopener noreferrer">About</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://twitter.com/plebchan_eth" target="_blank" rel="noopener noreferrer">Twitter</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
<a style={{ textDecoration: 'underline' }} href="https://github.com/plebbit/plebchan/releases/latest" target="_blank" rel="noopener noreferrer">App</a>
|
||||
•
|
||||
<a style={{ textDecoration: 'underline' }} href="https://twitter.com/plebchan_eth" target="_blank" rel="noopener noreferrer">Twitter</a>
|
||||
•
|
||||
<a style={{ textDecoration: 'underline' }} href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
</div>
|
||||
</Footer>
|
||||
</Container>
|
||||
</Footer >
|
||||
</Container >
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
+484
-460
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,25 @@
|
||||
import { useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||
import { debounce } from 'lodash';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom';
|
||||
import { Tooltip } from 'react-tooltip';
|
||||
import { useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||
import { debounce } from 'lodash';
|
||||
import { Container, NavBar, Header, Break, PostMenu, PostForm } from '../styled/views/Board.styled';
|
||||
import { TopBar, BoardForm, Footer, ReplyFormLink} from '../styled/views/Thread.styled';
|
||||
import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
||||
import ImageBanner from '../ImageBanner';
|
||||
import Post from '../Post';
|
||||
import CreateBoardModal from '../modals/CreateBoardModal';
|
||||
import AdminListModal from '../modals/AdminListModal';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import packageJson from '../../../package.json';
|
||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||
import getDate from '../../utils/getDate';
|
||||
import handleImageClick from '../../utils/handleImageClick';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||
import packageJson from '../../../package.json'
|
||||
const {version} = packageJson
|
||||
import ImageBanner from '../ImageBanner';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import Post from '../Post';
|
||||
import AdminListModal from '../modals/AdminListModal';
|
||||
import CreateBoardModal from '../modals/CreateBoardModal';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import { Break, Container, Header, NavBar, PostForm, PostMenu } from '../styled/views/Board.styled';
|
||||
import { PostMenuCatalog } from '../styled/views/Catalog.styled';
|
||||
import { BoardForm, Footer, ReplyFormLink, TopBar } from '../styled/views/Thread.styled';
|
||||
const { version } = packageJson
|
||||
|
||||
|
||||
const Description = () => {
|
||||
@@ -31,7 +31,7 @@ const Description = () => {
|
||||
selectedThread,
|
||||
setSelectedTitle,
|
||||
} = useGeneralStore(state => state);
|
||||
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const threadMenuRefs = useRef({});
|
||||
@@ -41,13 +41,13 @@ const Description = () => {
|
||||
const [isAdminListOpen, setIsAdminListOpen] = useState(false);
|
||||
const [prevScrollPos, setPrevScrollPos] = useState(0);
|
||||
const [visible, setVisible] = useState(true);
|
||||
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||
const [openMenuCid, setOpenMenuCid] = useState(null);
|
||||
const [isCreateBoardOpen, setIsCreateBoardOpen] = useState(false);
|
||||
|
||||
const { subplebbitAddress } = useParams();
|
||||
const subplebbit = useSubplebbit({subplebbitAddress: selectedAddress});
|
||||
|
||||
const { subplebbitAddress, threadCid } = useParams();
|
||||
const subplebbit = useSubplebbit({ subplebbitAddress: selectedAddress });
|
||||
|
||||
|
||||
const handleOptionClick = () => {
|
||||
setOpenMenuCid(null);
|
||||
@@ -66,13 +66,13 @@ const Description = () => {
|
||||
} else {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
}
|
||||
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
};
|
||||
}, [openMenuCid, handleOutsideClick]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, []);
|
||||
@@ -99,9 +99,9 @@ const Description = () => {
|
||||
setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10);
|
||||
setPrevScrollPos(currentScrollPos);
|
||||
}, 50);
|
||||
|
||||
|
||||
window.addEventListener('scroll', debouncedHandleScroll);
|
||||
|
||||
|
||||
return () => window.removeEventListener('scroll', debouncedHandleScroll);
|
||||
}, [prevScrollPos, visible]);
|
||||
|
||||
@@ -127,57 +127,57 @@ const Description = () => {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
<title>
|
||||
{"Board Description - " + (subplebbit.title || subplebbit.address) + " - plebchan"}
|
||||
</title>
|
||||
</Helmet>
|
||||
</title>
|
||||
</Helmet>
|
||||
<Container>
|
||||
<CreateBoardModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isCreateBoardOpen}
|
||||
closeModal={() => setIsCreateBoardOpen(false)} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isCreateBoardOpen}
|
||||
closeModal={() => setIsCreateBoardOpen(false)} />
|
||||
<AdminListModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isAdminListOpen}
|
||||
closeModal={() => setIsAdminListOpen(false)}
|
||||
roles={subplebbit.roles} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isAdminListOpen}
|
||||
closeModal={() => setIsAdminListOpen(false)}
|
||||
roles={subplebbit.roles} />
|
||||
<SettingsModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isSettingsOpen}
|
||||
closeModal={() => setIsSettingsOpen(false)} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isSettingsOpen}
|
||||
closeModal={() => setIsSettingsOpen(false)} />
|
||||
<NavBar selectedStyle={selectedStyle}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/all`} onClick={() => window.scrollTo(0, 0)}>All</Link>
|
||||
/
|
||||
/
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
@@ -196,20 +196,20 @@ const Description = () => {
|
||||
<option value="all">All</option>
|
||||
<option value="subscriptions">Subscriptions</option>
|
||||
{defaultSubplebbits.map(subplebbit => (
|
||||
<option key={`option-${subplebbit.address}`} value={subplebbit.address}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</option>
|
||||
))}
|
||||
</select>
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
<option key={`option-${subplebbit.address}`} value={subplebbit.address}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</option>
|
||||
))}
|
||||
</select>
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
}>Create Board</span>
|
||||
</div>
|
||||
<div className="page-jump">
|
||||
<Link to={`/p/${selectedAddress}/c/${selectedThread}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
|
||||
<Link to="/" onClick={() => {handleStyleChange({target: {value: "Yotsuba"}}); window.scrollTo(0, 0);}}>Home</Link>
|
||||
<Link to="/" onClick={() => { handleStyleChange({ target: { value: "Yotsuba" } }); window.scrollTo(0, 0); }}>Home</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -222,33 +222,43 @@ const Description = () => {
|
||||
<div className="banner">
|
||||
<ImageBanner />
|
||||
</div>
|
||||
<>
|
||||
<>
|
||||
<div className="board-title">{subplebbit.title ?? null}</div>
|
||||
<div className="board-address">p/{subplebbit.address}
|
||||
<OfflineIndicator
|
||||
address={subplebbit.address}
|
||||
className="offline"
|
||||
tooltipPlace="top" />
|
||||
<OfflineIndicator
|
||||
address={subplebbit.address}
|
||||
className="offline"
|
||||
tooltipPlace="top" />
|
||||
</div>
|
||||
</>
|
||||
</>
|
||||
</>
|
||||
</Header>
|
||||
<Break selectedStyle={selectedStyle} />
|
||||
<PostForm selectedStyle={selectedStyle}>
|
||||
<ReplyFormLink id="post-form-link" selectedStyle={selectedStyle} style={{marginBottom: '10px'}}>
|
||||
<div id="return-button-mobile">
|
||||
<span className="btn-wrap" onClick={()=> {window.scrollTo(0, 0)}}>
|
||||
<ReplyFormLink id="post-form-link" selectedStyle={selectedStyle} style={{ marginBottom: '10px' }}>
|
||||
<div id="return-button-mobile">
|
||||
<span className="btn-wrap" onClick={() => { window.scrollTo(0, 0) }}>
|
||||
<Link to={`/p/${selectedAddress}`}>Return</Link>
|
||||
</span>
|
||||
</div>
|
||||
<div id="reload-button-mobile">
|
||||
|
||||
<span className="reload-button catalog-button" id="bottom-button-desktop-description">
|
||||
[
|
||||
<span id="button" style={{ cursor: 'pointer' }} onClick={() => window.location.reload()}
|
||||
onMouseOver={(event) => event.target.style.cursor = 'pointer'}
|
||||
onTouchStart={() => window.location.reload()}>Refresh</span>
|
||||
]
|
||||
</span>
|
||||
</div>
|
||||
<div id="catalog-button-mobile">
|
||||
<span className="btn-wrap">
|
||||
<Link to={`/p/${selectedAddress}/catalog`} onClick={()=> {window.scrollTo(0, 0)}}>Catalog</Link>
|
||||
<Link to={`/p/${selectedAddress}/catalog`} onClick={() => { window.scrollTo(0, 0) }}>Catalog</Link>
|
||||
</span>
|
||||
</div>
|
||||
<div id="bottom-button-mobile">
|
||||
<span className="btn-wrap">
|
||||
<span style={{cursor: 'pointer'}} onClick={() => window.scrollTo(0, document.body.scrollHeight)} onMouseOver={(event) => event.target.style.cursor='pointer'}>Bottom</span>
|
||||
<span style={{ cursor: 'pointer' }} onClick={() => window.scrollTo(0, document.body.scrollHeight)} onMouseOver={(event) => event.target.style.cursor = 'pointer'}>Bottom</span>
|
||||
</span>
|
||||
</div>
|
||||
</ReplyFormLink>
|
||||
@@ -256,7 +266,7 @@ const Description = () => {
|
||||
<TopBar selectedStyle={selectedStyle}>
|
||||
<span className="style-changer">
|
||||
Style:
|
||||
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
@@ -271,6 +281,13 @@ const Description = () => {
|
||||
<Link to={`/p/${selectedAddress}`}>Return</Link>
|
||||
]
|
||||
</span>
|
||||
<span className="return-button catalog-button" id="refresh-button-desktop">
|
||||
[
|
||||
<span id="button" style={{ cursor: 'pointer' }} onClick={() => window.location.reload()}
|
||||
onMouseOver={(event) => event.target.style.cursor = 'pointer'}
|
||||
onTouchStart={() => window.location.reload()}>Refresh</span>
|
||||
]
|
||||
</span>
|
||||
<span className="return-button catalog-button" id="catalog-button-desktop">
|
||||
[
|
||||
<Link to={`/p/${selectedAddress}/catalog`}>Catalog</Link>
|
||||
@@ -278,9 +295,9 @@ const Description = () => {
|
||||
</span>
|
||||
<span className="return-button catalog-button" id="bottom-button-desktop">
|
||||
[
|
||||
<span id="button" style={{cursor: 'pointer'}} onClick={() => window.scrollTo(0, document.body.scrollHeight)}
|
||||
onMouseOver={(event) => event.target.style.cursor='pointer'}
|
||||
onTouchStart={() => window.scrollTo(0, document.body.scrollHeight)}>Bottom</span>
|
||||
<span id="button" style={{ cursor: 'pointer' }} onClick={() => window.scrollTo(0, document.body.scrollHeight)}
|
||||
onMouseOver={(event) => event.target.style.cursor = 'pointer'}
|
||||
onTouchStart={() => window.scrollTo(0, document.body.scrollHeight)}>Bottom</span>
|
||||
]
|
||||
</span>
|
||||
</TopBar>
|
||||
@@ -289,86 +306,88 @@ const Description = () => {
|
||||
<>
|
||||
<div className="thread">
|
||||
<div className="op-container" style={{
|
||||
display: subplebbit.rules ? "grid" : "block",
|
||||
marginBottom: '10px',
|
||||
display: subplebbit.rules ? "grid" : "block",
|
||||
marginBottom: '10px',
|
||||
}}>
|
||||
<div className="post op op-desktop">
|
||||
<hr />
|
||||
<div className="post-info">
|
||||
{subplebbit.suggested?.avatarUrl ? (
|
||||
<div className="file" style={{marginBottom: "5px"}}>
|
||||
<div className="file" style={{ marginBottom: "5px" }}>
|
||||
<div className="file-text">
|
||||
Link:
|
||||
<a href={subplebbit.suggested?.avatarUrl}
|
||||
target="_blank" rel="noopener noreferrer">{
|
||||
subplebbit.suggested?.avatarUrl.length > 30 ?
|
||||
subplebbit.suggested?.avatarUrl.slice(0, 30) + "..." :
|
||||
subplebbit.suggested?.avatarUrl
|
||||
}
|
||||
<a href={subplebbit.suggested?.avatarUrl}
|
||||
target="_blank" rel="noopener noreferrer">{
|
||||
subplebbit.suggested?.avatarUrl.length > 30 ?
|
||||
subplebbit.suggested?.avatarUrl.slice(0, 30) + "..." :
|
||||
subplebbit.suggested?.avatarUrl
|
||||
}
|
||||
</a> (image)
|
||||
</div>
|
||||
<div className="img-container">
|
||||
<span className="file-thumb">
|
||||
<img src={subplebbit.suggested?.avatarUrl} alt="board avatar"
|
||||
onClick={handleImageClick}
|
||||
style={{cursor: "pointer"}} />
|
||||
onClick={handleImageClick}
|
||||
style={{ cursor: "pointer" }} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
) : null}
|
||||
<span className="name-block">
|
||||
<span className="title">Welcome to {subplebbit.title || subplebbit.address}</span>
|
||||
|
||||
<span className="name capcode"
|
||||
style={{cursor: 'pointer'}}
|
||||
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => { setIsAdminListOpen(!isAdminListOpen) }}
|
||||
>## Board Admins</span>
|
||||
|
||||
<span className="date-time">{getDate(subplebbit.createdAt)}</span>
|
||||
|
||||
<img src="assets/sticky.gif" alt="Sticky" title="Sticky" style={{marginBottom: "-1px", imageRendering: 'pixelated'}} />
|
||||
<img src="assets/sticky.gif" alt="Sticky" title="Sticky" style={{ marginBottom: "-1px", imageRendering: 'pixelated' }} />
|
||||
|
||||
<img src="assets/closed.gif" alt="Closed" title="Closed" style={{marginBottom: "-1px", imageRendering: 'pixelated'}} />
|
||||
<img src="assets/closed.gif" alt="Closed" title="Closed" style={{ marginBottom: "-1px", imageRendering: 'pixelated' }} />
|
||||
<span>
|
||||
[
|
||||
<Link to={() => {}} style={{textDecoration: "none"}} className="reply-link">Reply</Link>
|
||||
]
|
||||
[
|
||||
<Link to={() => { }} style={{ textDecoration: "none" }} className="reply-link">Reply</Link>
|
||||
]
|
||||
</span>
|
||||
<PostMenu
|
||||
<PostMenu
|
||||
title="Post menu"
|
||||
ref={el => {
|
||||
ref={el => {
|
||||
threadMenuRefs.current[subplebbit.pubsubTopic] = el;
|
||||
}}
|
||||
className='post-menu-button'
|
||||
className='post-menu-button'
|
||||
rotated={openMenuCid === subplebbit.pubsubTopic}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
const rect = threadMenuRefs.current[subplebbit.pubsubTopic].getBoundingClientRect();
|
||||
setMenuPosition({top: rect.top + window.scrollY, left: rect.left});
|
||||
setMenuPosition({ top: rect.top + window.scrollY, left: rect.left });
|
||||
setOpenMenuCid(prevCid => (prevCid === subplebbit.pubsubTopic ? null : subplebbit.pubsubTopic));
|
||||
}}
|
||||
>
|
||||
▶
|
||||
</PostMenu>
|
||||
{createPortal(
|
||||
<PostMenuCatalog selectedStyle={selectedStyle}
|
||||
ref={el => {postMenuCatalogRef.current = el}}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
style={{position: "absolute",
|
||||
top: menuPosition.top + 7,
|
||||
left: menuPosition.left}}>
|
||||
<div className={`post-menu-thread post-menu-thread-${subplebbit.pubsubTopic}`}
|
||||
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
||||
>
|
||||
<ul className="post-menu-catalog">
|
||||
<li onClick={() => handleOptionClick(subplebbit.pubsubTopic)}>Hide thread</li>
|
||||
{/* {isModerator ? (
|
||||
<PostMenuCatalog selectedStyle={selectedStyle}
|
||||
ref={el => { postMenuCatalogRef.current = el }}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: menuPosition.top + 7,
|
||||
left: menuPosition.left
|
||||
}}>
|
||||
<div className={`post-menu-thread post-menu-thread-${subplebbit.pubsubTopic}`}
|
||||
style={{ display: openMenuCid === subplebbit.pubsubTopic ? 'block' : 'none' }}
|
||||
>
|
||||
<ul className="post-menu-catalog">
|
||||
<li onClick={() => handleOptionClick(subplebbit.pubsubTopic)}>Hide thread</li>
|
||||
{/* {isModerator ? (
|
||||
<>
|
||||
change description
|
||||
</>
|
||||
) : null} */}
|
||||
</ul>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</PostMenuCatalog>, document.body
|
||||
)}
|
||||
</span>
|
||||
@@ -387,22 +406,22 @@ const Description = () => {
|
||||
<div className="post op op-mobile">
|
||||
<div className="post-info-mobile">
|
||||
<button className="post-menu-button-mobile"
|
||||
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
||||
style={{ all: 'unset', cursor: 'pointer' }}>...</button>
|
||||
<span className="name-block-mobile">
|
||||
<span className="name-mobile capcode"
|
||||
style={{cursor: 'pointer'}}
|
||||
onClick={() => {setIsAdminListOpen(!isAdminListOpen)}}
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => { setIsAdminListOpen(!isAdminListOpen) }}
|
||||
>## Board Admins</span>
|
||||
|
||||
<span className="thread-icons-mobile"
|
||||
style={{float: "right", marginRight: "18px"}}>
|
||||
<img src="assets/sticky.gif" alt="Sticky" title="Sticky" style={{marginTop: "-1px", marginRight: "2px", imageRendering: 'pixelated'}} />
|
||||
style={{ float: "right", marginRight: "18px" }}>
|
||||
<img src="assets/sticky.gif" alt="Sticky" title="Sticky" style={{ marginTop: "-1px", marginRight: "2px", imageRendering: 'pixelated' }} />
|
||||
|
||||
<img src="assets/closed.gif" alt="Closed" title="Closed" style={{marginTop: "-1px", marginRight: "2px", imageRendering: 'pixelated'}} />
|
||||
<img src="assets/closed.gif" alt="Closed" title="Closed" style={{ marginTop: "-1px", marginRight: "2px", imageRendering: 'pixelated' }} />
|
||||
</span>
|
||||
<br />
|
||||
<span className="subject-mobile"
|
||||
style={{marginBottom: "-15px"}}>Welcome to {subplebbit.title || subplebbit.address}</span>
|
||||
style={{ marginBottom: "-15px" }}>Welcome to {subplebbit.title || subplebbit.address}</span>
|
||||
|
||||
</span>
|
||||
<span className="date-time-mobile post-number-mobile">{getDate(subplebbit.createdAt)}</span>
|
||||
@@ -413,8 +432,8 @@ const Description = () => {
|
||||
<div className="img-container">
|
||||
<span className="file-thumb-mobile">
|
||||
<img src={subplebbit.suggested.avatarUrl} alt="board avatar"
|
||||
onClick={handleImageClick}
|
||||
style={{cursor: "pointer"}} />
|
||||
onClick={handleImageClick}
|
||||
style={{ cursor: "pointer" }} />
|
||||
<div className="file-info-mobile">image</div>
|
||||
</span>
|
||||
</div>
|
||||
@@ -427,7 +446,7 @@ const Description = () => {
|
||||
</blockquote>
|
||||
</div>
|
||||
<div className="post-link-mobile">
|
||||
<Link to={() => {}} className="button-mobile">View Thread</Link>
|
||||
<Link to={() => { }} className="button-mobile">View Thread</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -446,7 +465,7 @@ const Description = () => {
|
||||
marginTop: "2px",
|
||||
}}>
|
||||
Style:
|
||||
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
@@ -460,43 +479,43 @@ const Description = () => {
|
||||
marginTop: "42px",
|
||||
}}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/all`} onClick={() => window.scrollTo(0, 0)}>All</Link>
|
||||
/
|
||||
/
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
]
|
||||
</span>
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
]
|
||||
</span>
|
||||
))}
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
<Link to={`/p/${selectedAddress}/c/${selectedThread}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
]
|
||||
[
|
||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
||||
<Link to="/" onClick={() => handleStyleChange({ target: { value: "Yotsuba" } }
|
||||
)}>Home</Link>
|
||||
]
|
||||
</span>
|
||||
@@ -513,13 +532,13 @@ const Description = () => {
|
||||
marginTop: "5px",
|
||||
marginBottom: "15px",
|
||||
}}>
|
||||
<a style={{textDecoration: 'underline'}} href="https://plebbit.com" target="_blank" rel="noopener noreferrer">About</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://github.com/plebbit/plebchan/releases/latest" target="_blank" rel="noopener noreferrer">App</a>
|
||||
<a style={{ textDecoration: 'underline' }} href="https://plebbit.com" target="_blank" rel="noopener noreferrer">About</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://twitter.com/plebchan_eth" target="_blank" rel="noopener noreferrer">Twitter</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
<a style={{ textDecoration: 'underline' }} href="https://github.com/plebbit/plebchan/releases/latest" target="_blank" rel="noopener noreferrer">App</a>
|
||||
•
|
||||
<a style={{ textDecoration: 'underline' }} href="https://twitter.com/plebchan_eth" target="_blank" rel="noopener noreferrer">Twitter</a>
|
||||
•
|
||||
<a style={{ textDecoration: 'underline' }} href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
</div>
|
||||
</Footer>
|
||||
</Container>
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import { Link, useNavigate} from 'react-router-dom';
|
||||
import { confirmAlert } from 'react-confirm-alert';
|
||||
import { Tooltip } from 'react-tooltip';
|
||||
import { VirtuosoGrid } from 'react-virtuoso';
|
||||
import { useAccount, useFeed, usePublishCommentEdit, useSubplebbits } from '@plebbit/plebbit-react-hooks';
|
||||
import { debounce } from 'lodash';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { confirmAlert } from 'react-confirm-alert';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Helmet } from 'react-helmet-async';
|
||||
import InfiniteScroll from 'react-infinite-scroller';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Tooltip } from 'react-tooltip';
|
||||
import packageJson from '../../../package.json';
|
||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||
import { Container, NavBar, Header, Break, PostMenu, BoardForm } from '../styled/views/Board.styled';
|
||||
import { Threads, PostMenuCatalog, GridContainer } from '../styled/views/Catalog.styled';
|
||||
import { TopBar, Footer, AuthorDeleteAlert } from '../styled/views/Thread.styled';
|
||||
import CatalogLoader from '../CatalogLoader';
|
||||
import EditModal from '../modals/EditModal';
|
||||
import ImageBanner from '../ImageBanner';
|
||||
import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import CreateBoardModal from '../modals/CreateBoardModal';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import useError from '../../hooks/useError';
|
||||
import useFeedStateString from '../../hooks/useFeedStateString';
|
||||
import useSuccess from '../../hooks/useSuccess';
|
||||
import packageJson from '../../../package.json'
|
||||
const {version} = packageJson
|
||||
import countLinks from '../../utils/countLinks';
|
||||
import getCommentMediaInfo from '../../utils/getCommentMediaInfo';
|
||||
import handleStyleChange from '../../utils/handleStyleChange';
|
||||
import CatalogLoader from '../CatalogLoader';
|
||||
import ImageBanner from '../ImageBanner';
|
||||
import OfflineIndicator from '../OfflineIndicator';
|
||||
import VerifiedAuthor from '../VerifiedAuthor';
|
||||
import CreateBoardModal from '../modals/CreateBoardModal';
|
||||
import EditModal from '../modals/EditModal';
|
||||
import ModerationModal from '../modals/ModerationModal';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import { BoardForm, Break, Container, Header, NavBar, PostMenu } from '../styled/views/Board.styled';
|
||||
import { PostMenuCatalog, Threads } from '../styled/views/Catalog.styled';
|
||||
import { AuthorDeleteAlert, Footer, TopBar } from '../styled/views/Thread.styled';
|
||||
const { version } = packageJson
|
||||
|
||||
|
||||
const SubscriptionsCatalog = () => {
|
||||
@@ -67,27 +67,27 @@ const SubscriptionsCatalog = () => {
|
||||
const [deletePost, setDeletePost] = useState(false);
|
||||
const [isImageSearchOpen, setIsImageSearchOpen] = useState(false);
|
||||
const [commentCid, setCommentCid] = useState(null);
|
||||
const [menuPosition, setMenuPosition] = useState({top: 0, left: 0});
|
||||
const [menuPosition, setMenuPosition] = useState({ top: 0, left: 0 });
|
||||
const [openMenuCid, setOpenMenuCid] = useState(null);
|
||||
const [moderatorPermissions, setModeratorPermissions] = useState({});
|
||||
const [isCreateBoardOpen, setIsCreateBoardOpen] = useState(false);
|
||||
|
||||
const { feed, loadMore } = useFeed({subplebbitAddresses: account?.subscriptions, sortType: 'active'});
|
||||
const { feed, hasMore, loadMore } = useFeed({ subplebbitAddresses: account?.subscriptions, sortType: 'active' });
|
||||
const [selectedFeed, setSelectedFeed] = useState(feed.sort((a, b) => b.timestamp - a.timestamp));
|
||||
const {subplebbits} = useSubplebbits({subplebbitAddresses: account?.subscriptions, sortType: 'active'});
|
||||
const { subplebbits } = useSubplebbits({ subplebbitAddresses: account?.subscriptions, sortType: 'active' });
|
||||
|
||||
const stateString = useFeedStateString(subplebbits);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
let permissions = {};
|
||||
|
||||
|
||||
selectedFeed.forEach(thread => {
|
||||
const subplebbit = subplebbits.find(s => s && s.address === thread.subplebbitAddress);
|
||||
|
||||
if (subplebbit && subplebbit.roles) {
|
||||
|
||||
if (subplebbit && subplebbit.roles) {
|
||||
const role = subplebbit.roles[account?.author.address]?.role;
|
||||
|
||||
|
||||
if (role === 'moderator' || role === 'admin' || role === 'owner') {
|
||||
permissions[thread.subplebbitAddress] = true;
|
||||
} else {
|
||||
@@ -95,9 +95,9 @@ const SubscriptionsCatalog = () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setModeratorPermissions(permissions);
|
||||
}, [account?.author.address, selectedFeed, subplebbits]);
|
||||
}, [account?.author.address, selectedFeed, subplebbits]);
|
||||
|
||||
|
||||
const handleOptionClick = () => {
|
||||
@@ -118,7 +118,7 @@ const SubscriptionsCatalog = () => {
|
||||
} else {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
}
|
||||
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
};
|
||||
@@ -131,24 +131,23 @@ const SubscriptionsCatalog = () => {
|
||||
setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10);
|
||||
setPrevScrollPos(currentScrollPos);
|
||||
}, 50);
|
||||
|
||||
|
||||
window.addEventListener('scroll', debouncedHandleScroll);
|
||||
|
||||
|
||||
return () => window.removeEventListener('scroll', debouncedHandleScroll);
|
||||
}, [prevScrollPos, visible]);
|
||||
|
||||
|
||||
const tryLoadMore = async () => {
|
||||
try {loadMore()}
|
||||
catch (e)
|
||||
{await new Promise(resolve => setTimeout(resolve, 1000))}
|
||||
try { loadMore() }
|
||||
catch (e) { await new Promise(resolve => setTimeout(resolve, 1000)) }
|
||||
};
|
||||
|
||||
|
||||
const onChallengeVerification = (challengeVerification) => {
|
||||
if (challengeVerification.challengeSuccess === true) {
|
||||
setNewSuccessMessage('Challenge Success');
|
||||
}
|
||||
setNewSuccessMessage('Challenge Success');
|
||||
}
|
||||
else if (challengeVerification.challengeSuccess === false) {
|
||||
setNewErrorMessage(`Challenge Failed, reason: ${challengeVerification.reason}. Errors: ${challengeVerification.errors}`);
|
||||
console.log('challenge failed', challengeVerification);
|
||||
@@ -172,16 +171,16 @@ const SubscriptionsCatalog = () => {
|
||||
|
||||
const getChallengeAnswersFromUser = async (challenges) => {
|
||||
setChallengesArray(challenges);
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const imageString = challenges?.challenges[0].challenge;
|
||||
const imageSource = `data:image/png;base64,${imageString}`;
|
||||
const challengeImg = new Image();
|
||||
challengeImg.src = imageSource;
|
||||
|
||||
|
||||
challengeImg.onload = () => {
|
||||
setIsCaptchaOpen(true);
|
||||
|
||||
|
||||
const handleKeyDown = async (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
const currentCaptchaResponse = useGeneralStore.getState().captchaResponse;
|
||||
@@ -197,7 +196,7 @@ const SubscriptionsCatalog = () => {
|
||||
|
||||
setResolveCaptchaPromise(resolve);
|
||||
};
|
||||
|
||||
|
||||
challengeImg.onerror = () => {
|
||||
reject(setNewErrorMessage('Could not load challenges'));
|
||||
};
|
||||
@@ -214,8 +213,8 @@ const SubscriptionsCatalog = () => {
|
||||
setNewErrorMessage(error.message); console.log(error);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions);
|
||||
|
||||
|
||||
@@ -262,8 +261,8 @@ const SubscriptionsCatalog = () => {
|
||||
setOriginalCommentContent(comment.content);
|
||||
setIsEditModalOpen(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setPublishCommentEditOptions((prevOptions) => ({
|
||||
...prevOptions,
|
||||
@@ -279,7 +278,7 @@ const SubscriptionsCatalog = () => {
|
||||
}
|
||||
}, [editedComment, setIsAuthorEdit]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
let isActive = true;
|
||||
if (publishCommentEditOptions && triggerPublishCommentEdit) {
|
||||
@@ -325,60 +324,60 @@ const SubscriptionsCatalog = () => {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>Subscriptions - Catalog - plebchan</title>
|
||||
<title>Subscriptions - Catalog - plebchan</title>
|
||||
</Helmet>
|
||||
<Container>
|
||||
<CreateBoardModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isCreateBoardOpen}
|
||||
closeModal={() => setIsCreateBoardOpen(false)} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isCreateBoardOpen}
|
||||
closeModal={() => setIsCreateBoardOpen(false)} />
|
||||
<SettingsModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isSettingsOpen}
|
||||
closeModal={() => setIsSettingsOpen(false)} />
|
||||
<ModerationModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isModerationOpen}
|
||||
closeModal={() => {setIsModerationOpen(false); setDeletePost(false)}}
|
||||
deletePost={deletePost} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isSettingsOpen}
|
||||
closeModal={() => setIsSettingsOpen(false)} />
|
||||
<ModerationModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isModerationOpen}
|
||||
closeModal={() => { setIsModerationOpen(false); setDeletePost(false) }}
|
||||
deletePost={deletePost} />
|
||||
<EditModal
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isEditModalOpen}
|
||||
closeModal={() => setIsEditModalOpen(false)}
|
||||
originalCommentContent={originalCommentContent} />
|
||||
selectedStyle={selectedStyle}
|
||||
isOpen={isEditModalOpen}
|
||||
closeModal={() => setIsEditModalOpen(false)}
|
||||
originalCommentContent={originalCommentContent} />
|
||||
<NavBar selectedStyle={selectedStyle}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/all`} onClick={() => window.scrollTo(0, 0)}>All</Link>
|
||||
/
|
||||
/
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => {
|
||||
setSelectedTitle(subplebbit.title);
|
||||
setSelectedAddress(subplebbit.address);
|
||||
}}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
@@ -397,20 +396,20 @@ const SubscriptionsCatalog = () => {
|
||||
<option value="all">All</option>
|
||||
<option value="subscriptions">Subscriptions</option>
|
||||
{defaultSubplebbits.map(subplebbit => (
|
||||
<option key={`option-${subplebbit.address}`} value={subplebbit.address}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</option>
|
||||
))}
|
||||
</select>
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
<option key={`option-${subplebbit.address}`} value={subplebbit.address}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</option>
|
||||
))}
|
||||
</select>
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
}>Create Board</span>
|
||||
</div>
|
||||
<div className="page-jump">
|
||||
<Link to={`/p/subscriptions/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
|
||||
<Link to="/" onClick={() => {handleStyleChange({target: {value: "Yotsuba"}}); window.scrollTo(0, 0);}}>Home</Link>
|
||||
<Link to="/" onClick={() => { handleStyleChange({ target: { value: "Yotsuba" } }); window.scrollTo(0, 0); }}>Home</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -423,7 +422,7 @@ const SubscriptionsCatalog = () => {
|
||||
<div className="banner">
|
||||
<ImageBanner />
|
||||
</div>
|
||||
<>
|
||||
<>
|
||||
<div className="board-title">Subscriptions</div>
|
||||
{account?.subscriptions.length < 1 ? (
|
||||
<div className="board-address">You haven't subscribed to any board yet.</div>
|
||||
@@ -432,7 +431,7 @@ const SubscriptionsCatalog = () => {
|
||||
You have subscribed to {account?.subscriptions.length} board{account?.subscriptions.length > 1 ? "s" : null}.
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
</>
|
||||
</>
|
||||
</Header>
|
||||
<Break selectedStyle={selectedStyle} />
|
||||
@@ -440,7 +439,7 @@ const SubscriptionsCatalog = () => {
|
||||
<hr />
|
||||
<span className="style-changer">
|
||||
Style:
|
||||
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
@@ -455,15 +454,27 @@ const SubscriptionsCatalog = () => {
|
||||
<Link to={`/p/subscriptions`}>Return</Link>
|
||||
]
|
||||
</div>
|
||||
<span className="return-button catalog-button" id="refresh-button-desktop">
|
||||
[
|
||||
<span id="button" style={{ cursor: 'pointer' }} onClick={() => window.location.reload()}
|
||||
onMouseOver={(event) => event.target.style.cursor = 'pointer'}
|
||||
onTouchStart={() => window.location.reload()}>Refresh</span>
|
||||
]
|
||||
</span>
|
||||
<div id="return-button-mobile">
|
||||
<span className="btn-wrap-catalog btn-wrap">
|
||||
<Link to={`/p/subscriptions`}>Return</Link>
|
||||
</span>
|
||||
</div>
|
||||
<div id="refresh-button-mobile">
|
||||
<span className="btn-wrap-catalog btn-wrap">
|
||||
<Link to={`/p/subscriptions/catalog`}>Refresh</Link>
|
||||
</span>
|
||||
</div>
|
||||
{subplebbits.state === "succeeded" ? (
|
||||
null
|
||||
) : (
|
||||
<div id="stats" style={{float: "right", marginTop: "5px"}}>
|
||||
<div id="stats" style={{ float: "right", marginTop: "5px" }}>
|
||||
<span className={stateString ? "ellipsis" : ""}>{stateString}</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -471,75 +482,76 @@ const SubscriptionsCatalog = () => {
|
||||
</TopBar>
|
||||
<Tooltip id="tooltip" className="tooltip" />
|
||||
<Threads selectedStyle={selectedStyle}>
|
||||
{feed.length > 1 ? (
|
||||
<VirtuosoGrid
|
||||
style={{width: '100%', height: '100%'}}
|
||||
data={feed}
|
||||
increaseViewportBy={{bottom: 600, top: 600}}
|
||||
itemContent={(index) => {
|
||||
const thread = feed[index];
|
||||
{feed ? (
|
||||
<InfiniteScroll
|
||||
pageStart={0}
|
||||
loadMore={tryLoadMore}
|
||||
hasMore={hasMore}
|
||||
>
|
||||
{feed.map((thread, index) => {
|
||||
const commentMediaInfo = getCommentMediaInfo(thread);
|
||||
const fallbackImgUrl = "assets/filedeleted-res.gif";
|
||||
const isModerator = moderatorPermissions[thread.subplebbitAddress];
|
||||
const linkCount = countLinks(thread);
|
||||
return (
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => {setIsHoveringOnThread(thread.cid)}}
|
||||
onMouseLeave={() => {setIsHoveringOnThread('')}}>
|
||||
<div key={`thread-${index}`} className="thread"
|
||||
onMouseOver={() => { setIsHoveringOnThread(thread.cid) }}
|
||||
onMouseLeave={() => { setIsHoveringOnThread('') }}>
|
||||
{commentMediaInfo?.url ? (
|
||||
<Link style={{all: "unset", cursor: "pointer"}} key={`link-${index}`} to={`/p/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
<Link style={{ all: "unset", cursor: "pointer" }} key={`link-${index}`} to={`/p/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
{commentMediaInfo?.type === "webpage" ? (
|
||||
thread.thumbnailUrl ? (
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.thumbnail} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;
|
||||
}} />
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.thumbnail} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;
|
||||
}} />
|
||||
) : null
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "image" ? (
|
||||
<img className="card" key={`img-${index}`}
|
||||
src={commentMediaInfo.url} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;}} />
|
||||
src={commentMediaInfo.url} alt={commentMediaInfo.type}
|
||||
onError={(e) => {
|
||||
e.target.src = fallbackImgUrl
|
||||
e.target.onerror = null;
|
||||
}} />
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "video" ? (
|
||||
<video className="card" key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
<video className="card" key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
) : null}
|
||||
{commentMediaInfo?.type === "audio" ? (
|
||||
<audio className="card" controls
|
||||
key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
<audio className="card" controls
|
||||
key={`fti-${index}`}
|
||||
src={commentMediaInfo.url}
|
||||
alt={commentMediaInfo.type}
|
||||
onError={(e) => e.target.src = fallbackImgUrl} />
|
||||
) : null}
|
||||
</Link>
|
||||
) : null}
|
||||
<div key={`ti-${index}`} className="thread-icons" >
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
commentMediaInfo.type === 'video' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon"
|
||||
tooltipPlace="top" />
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
commentMediaInfo.type === 'video' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon"
|
||||
tooltipPlace="top" />
|
||||
) : (
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon-no-link"
|
||||
tooltipPlace="top" />
|
||||
)}
|
||||
<OfflineIndicator
|
||||
address={thread.subplebbitAddress}
|
||||
className="thread-icon offline-icon-no-link"
|
||||
tooltipPlace="top" />
|
||||
)}
|
||||
</div>
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset"}}>
|
||||
<BoardForm selectedStyle={selectedStyle}
|
||||
style={{ all: "unset" }}>
|
||||
<div key={`meta-${index}`} className="meta" title="(R)eplies / (L)ink Replies" >
|
||||
R: <b key={`b-${index}`}>{thread.replyCount}</b>
|
||||
{linkCount > 0 ? (
|
||||
@@ -548,45 +560,49 @@ const SubscriptionsCatalog = () => {
|
||||
L: <b key={`i-${index}`}>{linkCount}</b>
|
||||
</>
|
||||
) : null}
|
||||
<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;
|
||||
postMenuRef.current = el;
|
||||
}}
|
||||
className='post-menu-button'
|
||||
id='post-menu-button-catalog'
|
||||
rotated={openMenuCid === thread.cid}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
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>
|
||||
<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;
|
||||
postMenuRef.current = el;
|
||||
}}
|
||||
className='post-menu-button'
|
||||
id='post-menu-button-catalog'
|
||||
rotated={openMenuCid === thread.cid}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
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}
|
||||
ref={el => {postMenuCatalogRef.current = el}}
|
||||
<PostMenuCatalog selectedStyle={selectedStyle}
|
||||
ref={el => { postMenuCatalogRef.current = el }}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
style={{position: "absolute",
|
||||
top: menuPosition.top + 7,
|
||||
left: menuPosition.left}}>
|
||||
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' }}
|
||||
style={{ display: openMenuCid === thread.cid ? 'block' : 'none' }}
|
||||
>
|
||||
<ul className="post-menu-catalog">
|
||||
<li onClick={() => handleOptionClick(thread.cid)}>Hide thread</li>
|
||||
<VerifiedAuthor commentCid={thread.cid}>{({ authorAddress }) => (
|
||||
<>
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
<>
|
||||
<li onClick={() => handleAuthorEditClick(thread)}>Edit post</li>
|
||||
<li onClick={() => handleAuthorDeleteClick(thread)}>Delete post</li>
|
||||
@@ -595,26 +611,26 @@ const SubscriptionsCatalog = () => {
|
||||
{isModerator ? (
|
||||
<>
|
||||
{authorAddress === account?.author.address ||
|
||||
authorAddress === account?.signer.address ? (
|
||||
authorAddress === account?.signer.address ? (
|
||||
null
|
||||
) : (
|
||||
<li onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
setDeletePost(true);
|
||||
}}>
|
||||
Delete post
|
||||
Delete post
|
||||
</li>
|
||||
)}
|
||||
<li
|
||||
onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
}}>
|
||||
onClick={() => {
|
||||
setSelectedAddress(thread.subplebbitAddress);
|
||||
setModeratingCommentCid(thread.cid)
|
||||
setIsModerationOpen(true);
|
||||
handleOptionClick(thread.cid);
|
||||
}}>
|
||||
Mod tools
|
||||
</li>
|
||||
</>
|
||||
@@ -622,57 +638,56 @@ const SubscriptionsCatalog = () => {
|
||||
</>
|
||||
)}</VerifiedAuthor>
|
||||
{(commentMediaInfo && (
|
||||
commentMediaInfo.type === 'image' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<li
|
||||
onMouseOver={() => {setIsImageSearchOpen(true)}}
|
||||
onMouseLeave={() => {setIsImageSearchOpen(false)}}>
|
||||
Image search »
|
||||
<ul className="dropdown-menu post-menu-catalog"
|
||||
style={{display: isImageSearchOpen ? 'block': 'none'}}>
|
||||
<li onClick={() => handleOptionClick(thread.cid)}>
|
||||
<a
|
||||
commentMediaInfo.type === 'image' ||
|
||||
(commentMediaInfo.type === 'webpage' &&
|
||||
commentMediaInfo.thumbnail))) ? (
|
||||
<li
|
||||
onMouseOver={() => { setIsImageSearchOpen(true) }}
|
||||
onMouseLeave={() => { setIsImageSearchOpen(false) }}>
|
||||
Image search »
|
||||
<ul className="dropdown-menu post-menu-catalog"
|
||||
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
|
||||
>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
|
||||
>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
|
||||
>SauceNAO</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
) : null
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</PostMenuCatalog>, document.body
|
||||
)}
|
||||
</BoardForm>
|
||||
<Link style={{all: "unset", cursor: "pointer"}} key={`link2-${index}`} to={`/p/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
<Link style={{ all: "unset", cursor: "pointer" }} key={`link2-${index}`} to={`/p/${thread.subplebbitAddress}/c/${thread.cid}`}
|
||||
onClick={() => setSelectedThread(thread.cid)}>
|
||||
<div key={`t-${index}`} className="teaser">
|
||||
<b key={`b2-${index}`}>{thread.title ? `${thread.title}` : null}</b>
|
||||
{thread.content ? `: ${thread.content}` : null}
|
||||
</div>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
endReached={tryLoadMore}
|
||||
useWindowScroll={true}
|
||||
components={{List: GridContainer}}
|
||||
/>
|
||||
) : (<CatalogLoader />)}
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
) : (
|
||||
<CatalogLoader />
|
||||
)}
|
||||
</Threads>
|
||||
<Footer selectedStyle={selectedStyle}>
|
||||
<Break id="break" selectedStyle={selectedStyle} style={{
|
||||
@@ -687,7 +702,7 @@ const SubscriptionsCatalog = () => {
|
||||
marginTop: "2px",
|
||||
}}>
|
||||
Style:
|
||||
|
||||
|
||||
<select id="style-selector" onChange={handleStyleChange} value={selectedStyle}>
|
||||
<option value="Yotsuba">Yotsuba</option>
|
||||
<option value="Yotsuba-B">Yotsuba B</option>
|
||||
@@ -700,40 +715,40 @@ const SubscriptionsCatalog = () => {
|
||||
<NavBar selectedStyle={selectedStyle} style={{
|
||||
marginTop: "42px",
|
||||
}}>
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<>
|
||||
<span className="boardList">
|
||||
[
|
||||
<Link to={`/p/subscriptions`} onClick={() => window.scrollTo(0, 0)}>Subscriptions</Link>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => handleClickTitle(subplebbit.title, subplebbit.address)}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
] [
|
||||
{defaultSubplebbits.map((subplebbit, index) => (
|
||||
<span className="boardList" key={`span-${subplebbit.address}`}>
|
||||
{index === 0 ? null : "\u00a0"}
|
||||
<Link to={`/p/${subplebbit.address}`} key={`a-${subplebbit.address}`} onClick={() => handleClickTitle(subplebbit.title, subplebbit.address)}
|
||||
>{subplebbit.title ? subplebbit.title : subplebbit.address}</Link>
|
||||
{index !== defaultSubplebbits.length - 1 ? " /" : null}
|
||||
</span>
|
||||
))}
|
||||
]
|
||||
</span>
|
||||
<span className="nav">
|
||||
[
|
||||
<span id="button-span" style={{cursor: 'pointer'}} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan:\nhttps://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, use plebbit-cli:\nhttps://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
<span id="button-span" style={{ cursor: 'pointer' }} onClick={
|
||||
() => {
|
||||
window.electron && window.electron.isElectron ? (
|
||||
setIsCreateBoardOpen(true)
|
||||
) : (
|
||||
alert(
|
||||
'You can create a board with the desktop version of plebchan, which you can download from here: https://github.com/plebbit/plebchan/releases/latest\n\nIf you are comfortable with the command line, you can also run a board (called "subplebbit") using plebbit-cli: https://github.com/plebbit/plebbit-cli\n\n'
|
||||
)
|
||||
)
|
||||
}
|
||||
}>Create Board</span>
|
||||
]
|
||||
[
|
||||
<Link to={`/p/subscriptions/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||
]
|
||||
[
|
||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
||||
<Link to="/" onClick={() => handleStyleChange({ target: { value: "Yotsuba" } }
|
||||
)}>Home</Link>
|
||||
]
|
||||
</span>
|
||||
@@ -750,13 +765,13 @@ const SubscriptionsCatalog = () => {
|
||||
marginTop: "5px",
|
||||
marginBottom: "15px",
|
||||
}}>
|
||||
<a style={{textDecoration: 'underline'}} href="https://plebbit.com" target="_blank" rel="noopener noreferrer">About</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://github.com/plebbit/plebchan/releases/latest" target="_blank" rel="noopener noreferrer">App</a>
|
||||
<a style={{ textDecoration: 'underline' }} href="https://plebbit.com" target="_blank" rel="noopener noreferrer">About</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://twitter.com/plebchan_eth" target="_blank" rel="noopener noreferrer">Twitter</a>
|
||||
•
|
||||
<a style={{textDecoration: 'underline'}} href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
<a style={{ textDecoration: 'underline' }} href="https://github.com/plebbit/plebchan/releases/latest" target="_blank" rel="noopener noreferrer">App</a>
|
||||
•
|
||||
<a style={{ textDecoration: 'underline' }} href="https://twitter.com/plebchan_eth" target="_blank" rel="noopener noreferrer">Twitter</a>
|
||||
•
|
||||
<a style={{ textDecoration: 'underline' }} href="https://t.me/plebbit" target="_blank" rel="noopener noreferrer">Telegram</a>
|
||||
</div>
|
||||
</Footer>
|
||||
</Container>
|
||||
|
||||
+955
-913
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user