diff --git a/src/components/PostOnHover.jsx b/src/components/PostOnHover.jsx index 5683234a..fb3ee59a 100644 --- a/src/components/PostOnHover.jsx +++ b/src/components/PostOnHover.jsx @@ -36,154 +36,278 @@ const PostOnHover = ({ cid, feed }) => {
+ ) : null} + {replyMediaInfo?.type === "audio" ? ( + + + ) : null} +
+ {}} className="quotelink"> + {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null} + +++ (...) +
+ Comment too long. Click the link to view. +
{}} className="quotelink"> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null} -- - :- (...) -
- Comment too long. Click the link to view. -
- {}} className="quotelink"> - {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null} - -) - : null} +- -
+ {}} className="quotelink"> + {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null} + +++ (...) +
++
+ Comment too long. Click the link to view. +
+ {}} className="quotelink" > + {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null} + +) + : null} ++ +
{}} key={`mob-r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefsMobile.current[shortParentCid] = el; + }} onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} - onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefsMobile.current[shortParentCid].getBoundingClientRect(); + const distanceToRight = window.innerWidth - rect.right; + + if (distanceToRight < 200) { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + right: window.innerWidth - rect.left - 10, + maxWidth: rect.left - 5 + }); + + } else { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + maxWidth: window.innerWidth - rect.left - rect.width + 5 + }); + } + } + }); + }} onMouseLeave={() => { removeHighlight(); setOutOfViewCid(null); @@ -1741,8 +1772,37 @@ const Board = () => {
{}} key={`mob-r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefsMobile.current[shortParentCid] = el; + }} onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} - onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefsMobile.current[shortParentCid].getBoundingClientRect(); + const distanceToRight = window.innerWidth - rect.right; + + if (distanceToRight < 200) { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + right: window.innerWidth - rect.left - 10, + maxWidth: rect.left - 5 + }); + + } else { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + maxWidth: window.innerWidth - rect.left - rect.width + 5 + }); + } + } + }); + }} onMouseLeave={() => { removeHighlight(); setOutOfViewCid(null); @@ -1763,10 +1823,35 @@ const Board = () => { {reply.replies?.pages?.topAll.comments .sort((a, b) => a.timestamp - b.timestamp) .map((reply, index) => ( -+{ + backlinkRefsMobile.current[reply.cid] = el; + }}> {}} onClick={(event) => handleQuoteClick(reply, reply.shortCid, event)} - onMouseOver={() => handleQuoteHover(reply, reply.shortCid, (cid) => setOutOfViewCid(cid))} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, reply.shortCid, () => { + setOutOfViewCid(reply.cid) + const rect = backlinkRefsMobile.current[reply.cid].getBoundingClientRect(); + const distanceToRight = window.innerWidth - rect.right; + + if (distanceToRight < 200) { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + right: window.innerWidth - rect.left - 10, + maxWidth: rect.left - 5 + }); + + } else { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + maxWidth: window.innerWidth - rect.left - rect.width + 5 + }); + } + }); + }} onMouseLeave={() => { removeHighlight(); setOutOfViewCid(null); diff --git a/src/components/views/Catalog.jsx b/src/components/views/Catalog.jsx index 768f33c5..ce27cc83 100755 --- a/src/components/views/Catalog.jsx +++ b/src/components/views/Catalog.jsx @@ -78,7 +78,7 @@ const Catalog = () => { const [openMenuCid, setOpenMenuCid] = useState(null); - const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`${selectedAddress}`], sortType: 'new'}); + const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`${selectedAddress}`], sortType: 'active'}); const { subplebbitAddress } = useParams(); const subplebbit = useSubplebbit({subplebbitAddress: selectedAddress}); const account = useAccount(); diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index 4c05f48b..de8af6d3 100755 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -98,6 +98,8 @@ const Thread = () => { const [outOfViewCid, setOutOfViewCid] = useState(null); const [outOfViewPosition, setOutOfViewPosition] = useState({top: 0, left: 0}); const [postOnHoverHeight, setPostOnHoverHeight] = useState(0); + const backlinkRefsMobile = useRef({}); + const quoteRefsMobile = useRef({}); const comment = useComment({commentCid: selectedThread}); @@ -1519,12 +1521,41 @@ const Thread = () => { ) : null}handleQuoteClick(reply, shortParentCid, event)} - onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))} - onMouseLeave={() => { - removeHighlight(); - setOutOfViewCid(null); - }}> + ref={el => { + quoteRefsMobile.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === comment.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefsMobile.current[shortParentCid].getBoundingClientRect(); + const distanceToRight = window.innerWidth - rect.right; + + if (distanceToRight < 200) { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + right: window.innerWidth - rect.left - 10, + maxWidth: rect.left - 5 + }); + + } else { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + maxWidth: window.innerWidth - rect.left - rect.width + 5 + }); + } + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === comment.shortCid ? " (OP)" : null}@@ -1540,14 +1571,39 @@ const Thread = () => { {reply.replies?.pages?.topAll.comments .sort((a, b) => a.timestamp - b.timestamp) .map((reply, index) => ( - +{ + backlinkRefsMobile.current[reply.cid] = el; + }}> handleQuoteClick(reply, reply.shortCid, event)} - onMouseOver={() => handleQuoteHover(reply, reply.shortCid, (cid) => setOutOfViewCid(cid))} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, reply.shortCid, () => { + setOutOfViewCid(reply.cid) + const rect = backlinkRefsMobile.current[reply.cid].getBoundingClientRect(); + const distanceToRight = window.innerWidth - rect.right; + + if (distanceToRight < 200) { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + right: window.innerWidth - rect.left - 10, + maxWidth: rect.left - 5 + }); + + } else { + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + maxWidth: window.innerWidth - rect.left - rect.width + 5 + }); + } + }); + }} onMouseLeave={() => { removeHighlight(); setOutOfViewCid(null); - }}> + }} > c/{reply.shortCid}