diff --git a/package.json b/package.json index 0e5034ca..e90ab54a 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,12 @@ "@babel/plugin-syntax-flow": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.21.0", "@plebbit/plebbit-logger": "https://github.com/plebbit/plebbit-logger.git", - "@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks", + "@plebbit/plebbit-react-hooks": "https://github.com/plebbit/plebbit-react-hooks.git#1ee06ac4dae8f2fc330205031d86fc959d431fe0", "@testing-library/dom": "^9.0.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", - "@types/node": "^18.15.3", + "@types/node": "^18.15.5", "babel-plugin-styled-components": "^2.0.7", "eslint": "^8.36.0", "eslint-config-react-app": "^7.0.1", diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index 9ec60fac..13fb57b4 100644 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -7,7 +7,7 @@ import ImageBanner from '../ImageBanner'; import PostLoader from '../PostLoader'; import ReplyModal from '../ReplyModal'; import SettingsModal from '../SettingsModal'; -import { useFeed, useAccountsActions } from '@plebbit/plebbit-react-hooks'; +import { useFeed, usePublishComment } from '@plebbit/plebbit-react-hooks'; import InfiniteScroll from 'react-infinite-scroller'; import { Tooltip } from 'react-tooltip'; import handleStyleChange from '../../utils/handleStyleChange'; @@ -34,7 +34,7 @@ const Board = () => { const [name, setName] = useState(''); const [subject, setSubject] = useState(''); const [comment, setComment] = useState(''); - const { publishComment } = useAccountsActions(); + const { publishComment } = usePublishComment(); const [isCaptchaOpen, setIsCaptchaOpen] = useState(false); const [isReplyOpen, setIsReplyOpen] = useState(false); const [captchaImage, setCaptchaImage] = useState(''); @@ -42,7 +42,7 @@ const Board = () => { const [prevScrollPos, setPrevScrollPos] = useState(0); const [visible, setVisible] = useState(true); const [endIndex, setEndIndex] = useState(2); - const { feed, hasMore, loadMore } = useFeed([`${selectedAddress}`], 'new'); + const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: ['test2'], sortType: 'new'}); const [selectedFeed, setSelectedFeed] = useState(feed); const renderedFeed = selectedFeed.slice(0, endIndex); const { subplebbitAddress } = useParams(); diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index d8fbe4f5..23d689d0 100644 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -4,7 +4,7 @@ import useAppStore from '../../useAppStore'; import { Container, NavBar, Header, Break, PostForm, PostFormLink, PostFormTable } from './styles/Board.styled'; import { TopBar } from './styles/Thread.styled'; import { Threads } from './styles/Catalog.styled'; -import { useFeed, useAccountsActions } from '@plebbit/plebbit-react-hooks'; +import { useFeed, usePublishComment } from '@plebbit/plebbit-react-hooks'; import ImageBanner from '../ImageBanner'; import CaptchaModal from '../CaptchaModal'; import CatalogLoader from '../CatalogLoader'; @@ -32,13 +32,13 @@ const Catalog = () => { const [name, setName] = useState(''); const [subject, setSubject] = useState(''); const [comment, setComment] = useState(''); - const { publishComment } = useAccountsActions(); + const { publishComment } = usePublishComment(); const [isCaptchaOpen, setIsCaptchaOpen] = useState(false); const [captchaImage, setCaptchaImage] = useState(''); const navigate = useNavigate(); const [prevScrollPos, setPrevScrollPos] = useState(0); const [visible, setVisible] = useState(true); - const { feed, hasMore, loadMore } = useFeed([`${selectedAddress}`], 'new'); + const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`thisIsATest`], sortType: 'new'}); const { subplebbitAddress } = useParams(); const handleClickForm = useClickForm(); diff --git a/src/components/views/Home.jsx b/src/components/views/Home.jsx index 73278c3f..019890de 100644 --- a/src/components/views/Home.jsx +++ b/src/components/views/Home.jsx @@ -66,7 +66,7 @@ const Home = () => { {defaultSubplebbits.map(subplebbit => (
{subplebbit.title}
- { + { handleClick(subplebbit.title, subplebbit.address); }} > board logo diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 6a5d3656..2278f894 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -3,7 +3,7 @@ import { Link, useNavigate, useParams } from 'react-router-dom'; import useAppStore from '../../useAppStore'; import { Container, NavBar, Header, Break, PostForm, PostFormTable, BoardForm } from './styles/Board.styled'; import { ReplyFormLink, TopBar, BottomBar } from './styles/Thread.styled'; -import { useComment, useAccountsActions } from '@plebbit/plebbit-react-hooks'; +import { useComment, usePublishComment } from '@plebbit/plebbit-react-hooks'; import { Tooltip } from 'react-tooltip'; import CaptchaModal from '../CaptchaModal'; import ImageBanner from '../ImageBanner'; @@ -35,17 +35,21 @@ const Thread = () => { const [name, setName] = useState(''); const [subject, setSubject] = useState(''); const [commentContent, setCommentContent] = useState(''); - const { publishComment } = useAccountsActions(); + const { publishComment } = usePublishComment(); const [isCaptchaOpen, setIsCaptchaOpen] = useState(false); const [isReplyOpen, setIsReplyOpen] = useState(false); const [captchaImage, setCaptchaImage] = useState(''); const navigate = useNavigate(); const [prevScrollPos, setPrevScrollPos] = useState(0); const [visible, setVisible] = useState(true); - const comment = useComment(`${selectedThread}`); + const comment = useComment({selectedThread}); const { subplebbitAddress, threadCid } = useParams(); const handleClickForm = useClickForm(); + useEffect(() => { + console.log(comment); + }, [comment]); + // temporary title from JSON, gets subplebbitAddress and threadCid from URL useEffect(() => { @@ -418,37 +422,37 @@ const Thread = () => { ) : null}   - {comment.author.displayName - ? comment.author.displayName.length > 20 + {comment.author?.displayName + ? comment.author?.displayName.length > 20 ? <> - {comment.author.displayName.slice(0, 20) + " (...)"} + {comment.author?.displayName.slice(0, 20) + " (...)"} : - {comment.author.displayName} + {comment.author?.displayName} : Anonymous}     (u/ - {comment.author.address.length > 20 ? + {comment.author?.address.length > 20 ? <> - {comment.author.address.slice(0, 20) + "..."} + {comment.author?.address.slice(0, 20) + "..."} : - {comment.author.address} + {comment.author?.address} })   @@ -456,7 +460,7 @@ const Thread = () => {   c/ - +