fix useComment

This commit is contained in:
plebbitor
2023-03-25 15:34:10 +01:00
parent baf0ff2465
commit 1d7961de9b
3 changed files with 13 additions and 11 deletions
+6 -6
View File
@@ -426,7 +426,7 @@ const Board = () => {
) : null} ) : null}
{commentMediaInfo?.type === "video" ? ( {commentMediaInfo?.type === "video" ? (
<span key={`fta-${thread.cid}`} className="file-thumb"> <span key={`fta-${thread.cid}`} className="file-thumb">
{/* <VideoThumbnail <VideoThumbnail
videoUrl={commentMediaInfo.url} videoUrl={commentMediaInfo.url}
thumbnailHandler={(thumbnail) => { thumbnailHandler={(thumbnail) => {
const img = document.querySelector(`img[key="img-${thread.cid}"]`); const img = document.querySelector(`img[key="img-${thread.cid}"]`);
@@ -434,12 +434,12 @@ const Board = () => {
img.src = thumbnail; img.src = thumbnail;
} }
}} }}
/> */} />
</span> </span>
) : null} ) : null}
{commentMediaInfo?.type === "audio" ? ( {commentMediaInfo?.type === "audio" ? (
<span key={`fta-${thread.cid}`} className="file-thumb"> <span key={`fta-${thread.cid}`} className="file-thumb">
{/* <audio key={`fti-${thread.cid}`} src={commentMediaInfo.url} alt={commentMediaInfo.type} onError={(e) => e.target.src = fallbackImgUrl} /> */} <audio key={`fti-${thread.cid}`} src={commentMediaInfo.url} alt={commentMediaInfo.type} onError={(e) => e.target.src = fallbackImgUrl} />
</span> </span>
) : null} ) : null}
</div> </div>
@@ -721,7 +721,7 @@ const Board = () => {
) : commentMediaInfo.type === "video" ? ( ) : commentMediaInfo.type === "video" ? (
<div key={`mob-f-${thread.cid}`} className="file-mobile"> <div key={`mob-f-${thread.cid}`} className="file-mobile">
<span key={`mob-ft${thread.cid}`} className="file-thumb-mobile"> <span key={`mob-ft${thread.cid}`} className="file-thumb-mobile">
{/* <VideoThumbnail <VideoThumbnail
videoUrl={commentMediaInfo.url} videoUrl={commentMediaInfo.url}
thumbnailHandler={(thumbnail) => { thumbnailHandler={(thumbnail) => {
const img = document.querySelector(`img[key="img-${thread.cid}"]`); const img = document.querySelector(`img[key="img-${thread.cid}"]`);
@@ -729,14 +729,14 @@ const Board = () => {
img.src = thumbnail; img.src = thumbnail;
} }
}} }}
/> */} />
<div key={`mob-fi-${thread.cid}`} className="file-info-mobile">{commentMediaInfo.type}</div> <div key={`mob-fi-${thread.cid}`} className="file-info-mobile">{commentMediaInfo.type}</div>
</span> </span>
</div> </div>
) : commentMediaInfo.type === "audio" ? ( ) : commentMediaInfo.type === "audio" ? (
<div key={`mob-f-${thread.cid}`} className="file-mobile"> <div key={`mob-f-${thread.cid}`} className="file-mobile">
<span key={`mob-ft${thread.cid}`} className="file-thumb-mobile"> <span key={`mob-ft${thread.cid}`} className="file-thumb-mobile">
{/* <audio key={`mob-img-${thread.cid}`} src={commentMediaInfo.url} alt={commentMediaInfo.type} onError={(e) => e.target.src = fallbackImgUrl} /> */} <audio key={`mob-img-${thread.cid}`} src={commentMediaInfo.url} alt={commentMediaInfo.type} onError={(e) => e.target.src = fallbackImgUrl} />
<div key={`mob-fi-${thread.cid}`} className="file-info-mobile">{commentMediaInfo.type}</div> <div key={`mob-fi-${thread.cid}`} className="file-info-mobile">{commentMediaInfo.type}</div>
</span> </span>
</div> </div>
+1 -3
View File
@@ -45,9 +45,7 @@ const Catalog = () => {
const { subplebbitAddress } = useParams(); const { subplebbitAddress } = useParams();
const handleClickForm = useClickForm(); const handleClickForm = useClickForm();
useEffect(() => {
console.log(feed);
}, [feed]);
useEffect(() => { useEffect(() => {
setSelectedAddress(subplebbitAddress); setSelectedAddress(subplebbitAddress);
+6 -2
View File
@@ -44,13 +44,17 @@ const Thread = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const [prevScrollPos, setPrevScrollPos] = useState(0); const [prevScrollPos, setPrevScrollPos] = useState(0);
const [visible, setVisible] = useState(true); const [visible, setVisible] = useState(true);
const comment = useComment({selectedThread}); const comment = useComment({commentCid: selectedThread});
const { subplebbitAddress, threadCid } = useParams(); const { subplebbitAddress, threadCid } = useParams();
const handleClickForm = useClickForm(); const handleClickForm = useClickForm();
const commentMediaInfo = getCommentMediaInfo(comment); const commentMediaInfo = getCommentMediaInfo(comment);
const fallbackImgUrl = "/assets/filedeleted-res.gif"; const fallbackImgUrl = "/assets/filedeleted-res.gif";
// useEffect(() => {
// console.log(comment);
// }, [comment]);
// temporary title from JSON, gets subplebbitAddress and threadCid from URL // temporary title from JSON, gets subplebbitAddress and threadCid from URL
useEffect(() => { useEffect(() => {
@@ -390,7 +394,7 @@ const Thread = () => {
<hr /> <hr />
</TopBar> </TopBar>
<BoardForm selectedStyle={selectedStyle}> <BoardForm selectedStyle={selectedStyle}>
{comment ? ( {comment !== undefined ? (
<> <>
<div className="thread"> <div className="thread">
<div className="op-container"> <div className="op-container">