diff --git a/src/App.js b/src/App.js index 0123eb3f..a98e194f 100644 --- a/src/App.js +++ b/src/App.js @@ -58,13 +58,13 @@ export default function App() { } /> - }> + }> } /> - }> + }> } /> - }> + }> } /> diff --git a/src/components/Board.jsx b/src/components/Board.jsx index d8264825..d1caa3fe 100644 --- a/src/components/Board.jsx +++ b/src/components/Board.jsx @@ -28,17 +28,41 @@ const Board = ({ setBodyStyle }) => { const renderedFeed = selectedFeed.slice(startIndex, endIndex); - const handleScroll = (event) => { - const { scrollTop, scrollHeight, clientHeight } = event.currentTarget; - if (scrollTop + clientHeight >= scrollHeight) { - setEndIndex(endIndex + 5); - } - }; - useEffect(() => { setSelectedFeed(feed); }, [feed]); + useEffect(() => { + let didCancel = false; + fetch( + "https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/subplebbits.json", + { cache: "no-cache" } + ) + .then((res) => res.json()) + .then(res => { + if (!didCancel) { + setDefaultSubplebbits(res); + } + }); + return () => { + didCancel = true; + }; + }, []); + + useEffect(() => { + const handleScroll = () => { + const currentScrollPos = window.pageYOffset; + + setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10); + setPrevScrollPos(currentScrollPos); + }; + + window.addEventListener('scroll', handleScroll); + + return () => window.removeEventListener('scroll', handleScroll); + }, [prevScrollPos, visible]); + + const tryLoadMore = async () => { try { loadMore(); @@ -113,36 +137,14 @@ const Board = ({ setBodyStyle }) => { }); }; - useEffect(() => { - let didCancel = false; - fetch( - "https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/subplebbits.json", - { cache: "no-cache" } - ) - .then((res) => res.json()) - .then(res => { - if (!didCancel) { - setDefaultSubplebbits(res); - } - }); - return () => { - didCancel = true; - }; - }, []); - - useEffect(() => { - const handleScroll = () => { - const currentScrollPos = window.pageYOffset; - - setVisible(prevScrollPos > currentScrollPos || currentScrollPos < 10); - setPrevScrollPos(currentScrollPos); - }; - - window.addEventListener('scroll', handleScroll); - - return () => window.removeEventListener('scroll', handleScroll); - }, [prevScrollPos, visible]); + const handleScroll = (event) => { + const { scrollTop, scrollHeight, clientHeight } = event.currentTarget; + if (scrollTop + clientHeight >= scrollHeight) { + setEndIndex(endIndex + 5); + } + }; + const handleVoidClick = () => {} const handleClickTitle = (title, address) => { @@ -151,14 +153,6 @@ const Board = ({ setBodyStyle }) => { setSelectedFeed(feed.filter(feed => feed.title === title)); }; - const handleSelectChange = (event) => { - const selected = event.target.value; - const selectedTitle = defaultSubplebbits.find((subplebbit) => subplebbit.address === selected).title; - setSelectedTitle(selectedTitle); - setSelectedAddress(selected); - navigate(`/${selected}`); - } - const handleClickHelp = () => { alert("- The CAPTCHA loads after you click \"Post\" \n- The CAPTCHA is case-sensitive. \n- Make sure to not block any cookies set by plebchan."); }; @@ -166,12 +160,20 @@ const Board = ({ setBodyStyle }) => { const handleClickForm = () => { setShowPostFormLink(false); setShowPostForm(true); - navigate(`/${selectedAddress}/post`); + navigate(`/p/${selectedAddress}/post`); }; const handleClickThread = (thread) => { setSelectedThread(thread); } + + const handleSelectChange = (event) => { + const selected = event.target.value; + const selectedTitle = defaultSubplebbits.find((subplebbit) => subplebbit.address === selected).title; + setSelectedTitle(selectedTitle); + setSelectedAddress(selected); + navigate(`/p/${selected}`); + } const handlePublishComment = async () => { try { @@ -258,6 +260,7 @@ const Board = ({ setBodyStyle }) => { } } + function renderComments(comments) { return comments.map(comment => { const { replyCount, replies: { pages: { topAll: { comments: nestedComments } } } } = comment; @@ -278,7 +281,7 @@ const Board = ({ setBodyStyle }) => { {defaultSubplebbits.map(subplebbit => ( [ - handleClickTitle(subplebbit.title, subplebbit.address)} + handleClickTitle(subplebbit.title, subplebbit.address)} >{subplebbit.title} ]  @@ -397,12 +400,12 @@ const Board = ({ setBodyStyle }) => {
[ - Catalog + Catalog ]
- Catalog + Catalog
@@ -489,7 +492,7 @@ const Board = ({ setBodyStyle }) => {   [ - handleClickThread(thread.cid)} className="reply-link" >Reply + handleClickThread(thread.cid)} className="reply-link" >Reply ] @@ -508,7 +511,7 @@ const Board = ({ setBodyStyle }) => { (...)

Post too long.  - handleClickThread(thread.cid)} className="ttl-link">Click here + handleClickThread(thread.cid)} className="ttl-link">Click here  to view.
@@ -582,7 +585,7 @@ const Board = ({ setBodyStyle }) => { (...)

Comment too long.  - handleClickThread(thread.cid)} className="ttl-link">Click here + handleClickThread(thread.cid)} className="ttl-link">Click here  to view.
@@ -675,7 +678,7 @@ const Board = ({ setBodyStyle }) => { (...)

Post too long.  - handleClickThread(thread.cid)} className="ttl-link">Click here + handleClickThread(thread.cid)} className="ttl-link">Click here  to view.
@@ -686,7 +689,7 @@ const Board = ({ setBodyStyle }) => {
{thread.replyCount} Replies / ? Images - handleClickThread(thread.cid)} className="button-mobile" >View Thread + handleClickThread(thread.cid)} className="button-mobile" >View Thread
{renderedComments.map(reply => { @@ -750,7 +753,7 @@ const Board = ({ setBodyStyle }) => { (...)

Comment too long.  - handleClickThread(thread.cid)} className="ttl-link">Click here + handleClickThread(thread.cid)} className="ttl-link">Click here  to view.
diff --git a/src/components/Catalog.jsx b/src/components/Catalog.jsx index d8f55974..5f18237b 100644 --- a/src/components/Catalog.jsx +++ b/src/components/Catalog.jsx @@ -144,7 +144,7 @@ const Catalog = ({ setBodyStyle }) => { const handleClickForm = () => { setShowPostFormLink(false); setShowPostForm(true); - navigate(`/${selectedAddress}/catalog/post`); + navigate(`/p/${selectedAddress}/catalog/post`); }; const handleClickThread = (thread) => { @@ -245,7 +245,7 @@ const Catalog = ({ setBodyStyle }) => { {defaultSubplebbits.map(subplebbit => ( [ - handleClickTitle(subplebbit.title, subplebbit.address)} + handleClickTitle(subplebbit.title, subplebbit.address)} >{subplebbit.title} ]  @@ -364,12 +364,12 @@ const Catalog = ({ setBodyStyle }) => {
[ - Return + Return ]
- Return + Return

@@ -384,7 +384,7 @@ const Catalog = ({ setBodyStyle }) => { {feed.map(thread => { return (
- handleClickThread(thread.cid)}> + handleClickThread(thread.cid)}>
diff --git a/src/components/Home.jsx b/src/components/Home.jsx index 927a2f06..e8146fca 100644 --- a/src/components/Home.jsx +++ b/src/components/Home.jsx @@ -74,7 +74,7 @@ const Home = ({ setBodyStyle }) => { {defaultSubplebbits.map(subplebbit => (
{subplebbit.title}
- { + { handleClick(subplebbit.title, subplebbit.address); }} > board logo diff --git a/src/components/Thread.jsx b/src/components/Thread.jsx index d7d64ba8..67389e5a 100644 --- a/src/components/Thread.jsx +++ b/src/components/Thread.jsx @@ -70,7 +70,7 @@ const Thread = ({ setBodyStyle }) => { const handleClickForm = () => { setShowReplyFormLink(false); setShowReplyForm(true); - navigate(`/${selectedAddress}/thread/${selectedThread}/post`); + navigate(`/p/${selectedAddress}/thread/${selectedThread}/post`); }; const handleStyleChange = (event) => { @@ -223,12 +223,12 @@ const Thread = ({ setBodyStyle }) => {
- Return + Return
- Catalog + Catalog
@@ -303,12 +303,12 @@ const Thread = ({ setBodyStyle }) => { [ - Return + Return ] [ - Catalog + Catalog ] @@ -629,12 +629,12 @@ const Thread = ({ setBodyStyle }) => {
[ - Return + Return ] [ - Catalog + Catalog ] @@ -689,12 +689,12 @@ const Thread = ({ setBodyStyle }) => {
- Return + Return
- Catalog + Catalog