diff --git a/src/components/views/All.jsx b/src/components/views/All.jsx index b6e8d602..9b2263b9 100644 --- a/src/components/views/All.jsx +++ b/src/components/views/All.jsx @@ -49,7 +49,8 @@ const All = () => { const threadMenuRefs = useRef({}); const replyMenuRefs = useRef({}); - const threadBacklinkRefs = useRef({}); + const backlinkRefs = useRef({}); + const quoteRefs = useRef({}); const postOnHoverRef = useRef(null); const [isReplyOpen, setIsReplyOpen] = useState(false); @@ -534,7 +535,7 @@ const All = () => { .map((reply, index) => (
- {}} key={`r-pm-${index}`} className="quotelink" - onClick={(event) => handleQuoteClick(reply, shortParentCid, thread.shortCid, event)} - onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)} - onMouseLeave={removeHighlight}> + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + console.log("risposta: ", reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}@@ -839,10 +861,30 @@ const All = () => {
- {}} key={`r-pm-${index}`} className="quotelink" onClick={(event) => - handleQuoteClick(reply, shortParentCid, thread.shortCid, event)} - onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)} - onMouseLeave={removeHighlight}> + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}diff --git a/src/components/views/Board.jsx b/src/components/views/Board.jsx index 47d79b1e..5cbf4dd7 100644 --- a/src/components/views/Board.jsx +++ b/src/components/views/Board.jsx @@ -76,7 +76,8 @@ const Board = () => { const threadMenuRefs = useRef({}); const replyMenuRefs = useRef({}); const postMenuCatalogRef = useRef(null); - const threadBacklinkRefs = useRef({}); + const backlinkRefs = useRef({}); + const quoteRefs = useRef({}); const postOnHoverRef = useRef(null); const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`${selectedAddress}`], sortType: 'new'}); @@ -980,7 +981,7 @@ const Board = () => { .map((reply, index) => ( { - threadBacklinkRefs.current[reply.cid] = el; + backlinkRefs.current[reply.cid] = el; }}> {}} @@ -990,7 +991,7 @@ const Board = () => { event.stopPropagation(); handleQuoteHover(reply, null, () => { setOutOfViewCid(reply.cid); - const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect(); + const rect = backlinkRefs.current[reply.cid].getBoundingClientRect(); setOutOfViewPosition({ top: rect.top + window.scrollY - rect.height / 2, left: rect.left + rect.width + 5, @@ -1218,7 +1219,7 @@ const Board = () => { .map((reply, index) => ({ - threadBacklinkRefs.current[reply.cid] = el; + backlinkRefs.current[reply.cid] = el; }}> {}} className="quote-link" @@ -1227,7 +1228,7 @@ const Board = () => { event.stopPropagation(); handleQuoteHover(reply, null, () => { setOutOfViewCid(reply.cid); - const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect(); + const rect = backlinkRefs.current[reply.cid].getBoundingClientRect(); setOutOfViewPosition({ top: rect.top + window.scrollY - rect.height / 2, left: rect.left + rect.width + 5, @@ -1303,13 +1304,31 @@ const Board = () => { reply.content?.length > 500 ?: - {}} key={`r-pm-${index}`} className="quotelink" - onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} - onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))} - onMouseLeave={() => { - removeHighlight(); - setOutOfViewCid(null); - }}> + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + console.log("risposta: ", reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}@@ -1328,13 +1347,30 @@ const Board = () => { - {}} key={`r-pm-${index}`} className="quotelink" - onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} - onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))} - onMouseLeave={() => { - removeHighlight(); - setOutOfViewCid(null); - }}> + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}diff --git a/src/components/views/Subscriptions.jsx b/src/components/views/Subscriptions.jsx index 8d2a1080..256663f9 100644 --- a/src/components/views/Subscriptions.jsx +++ b/src/components/views/Subscriptions.jsx @@ -49,7 +49,8 @@ const Subscriptions = () => { const threadMenuRefs = useRef({}); const replyMenuRefs = useRef({}); - const threadBacklinkRefs = useRef({}); + const backlinkRefs = useRef({}); + const quoteRefs = useRef({}); const postOnHoverRef = useRef(null); const [isReplyOpen, setIsReplyOpen] = useState(false); @@ -539,7 +540,7 @@ const Subscriptions = () => { .map((reply, index) => ( { - threadBacklinkRefs.current[reply.cid] = el; + backlinkRefs.current[reply.cid] = el; }}> {}} className="quote-link" @@ -548,7 +549,7 @@ const Subscriptions = () => { event.stopPropagation(); handleQuoteHover(reply, null, () => { setOutOfViewCid(reply.cid); - const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect(); + const rect = backlinkRefs.current[reply.cid].getBoundingClientRect(); setOutOfViewPosition({ top: rect.top + window.scrollY - rect.height / 2, left: rect.left + rect.width + 5, @@ -744,7 +745,7 @@ const Subscriptions = () => { .map((reply, index) => ({ - threadBacklinkRefs.current[reply.cid] = el; + backlinkRefs.current[reply.cid] = el; }}> {}} className="quote-link" @@ -753,7 +754,7 @@ const Subscriptions = () => { event.stopPropagation(); handleQuoteHover(reply, null, () => { setOutOfViewCid(reply.cid); - const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect(); + const rect = backlinkRefs.current[reply.cid].getBoundingClientRect(); setOutOfViewPosition({ top: rect.top + window.scrollY - rect.height / 2, left: rect.left + rect.width + 5, @@ -829,10 +830,31 @@ const Subscriptions = () => { reply.content?.length > 500 ?: - {}} key={`r-pm-${index}`} className="quotelink" - onClick={(event) => handleQuoteClick(reply, shortParentCid, thread.shortCid, event)} - onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)} - onMouseLeave={removeHighlight}> + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + console.log("risposta: ", reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}@@ -844,10 +866,30 @@ const Subscriptions = () => { - {}} key={`r-pm-${index}`} className="quotelink" - onClick={(event) => handleQuoteClick(reply, shortParentCid, thread.shortCid, event)} - onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)} - onMouseLeave={removeHighlight}> + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; + }} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === thread.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} + onMouseLeave={() => { + removeHighlight(); + setOutOfViewCid(null); + }}> {`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}diff --git a/src/components/views/Thread.jsx b/src/components/views/Thread.jsx index bc73b18d..3e717ca0 100644 --- a/src/components/views/Thread.jsx +++ b/src/components/views/Thread.jsx @@ -75,7 +75,8 @@ const Thread = () => { const replyMenuRefs = useRef({}); const postMenuRef = useRef(null); const postMenuCatalogRef = useRef(null); - const threadBacklinkRefs = useRef({}); + const backlinkRefs = useRef({}); + const quoteRefs = useRef({}); const postOnHoverRef = useRef(null); const [triggerPublishComment, setTriggerPublishComment] = useState(false); @@ -938,7 +939,7 @@ const Thread = () => { .map((reply, index) => ( { - threadBacklinkRefs.current[reply.cid] = el; + backlinkRefs.current[reply.cid] = el; }}> {}} className="quote-link" @@ -947,7 +948,7 @@ const Thread = () => { event.stopPropagation(); handleQuoteHover(reply, null, () => { setOutOfViewCid(reply.cid); - const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect(); + const rect = backlinkRefs.current[reply.cid].getBoundingClientRect(); setOutOfViewPosition({ top: rect.top + window.scrollY - rect.height / 2, left: rect.left + rect.width + 5, @@ -1139,7 +1140,7 @@ const Thread = () => { .map((reply, index) => ({ - threadBacklinkRefs.current[reply.cid] = el; + backlinkRefs.current[reply.cid] = el; }}> {}} className="quote-link" @@ -1148,7 +1149,7 @@ const Thread = () => { event.stopPropagation(); handleQuoteHover(reply, null, () => { setOutOfViewCid(reply.cid); - const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect(); + const rect = backlinkRefs.current[reply.cid].getBoundingClientRect(); setOutOfViewPosition({ top: rect.top + window.scrollY - rect.height / 2, left: rect.left + rect.width + 5, @@ -1219,18 +1220,32 @@ const Thread = () => {) : null}- { - handleQuoteClick(reply, shortParentCid, comment.shortCid, event); + {}} key={`r-pm-${index}`} className="quotelink" + ref={el => { + quoteRefs.current[shortParentCid] = el; }} - onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))} + onClick={(event) => handleQuoteClick(reply, shortParentCid, event)} + onMouseOver={(event) => { + event.stopPropagation(); + handleQuoteHover(reply, shortParentCid, () => { + if (shortParentCid === comment.shortCid) { + return; + } else { + setOutOfViewCid(reply.parentCid); + const rect = quoteRefs.current[shortParentCid].getBoundingClientRect(); + setOutOfViewPosition({ + top: rect.top + window.scrollY - rect.height / 2, + left: rect.left + rect.width + 5, + }); + } + }); + }} onMouseLeave={() => { removeHighlight(); setOutOfViewCid(null); - }} - > - {`c/${shortParentCid}`}{shortParentCid === comment.shortCid ? " (OP)" : null} - + }}> + {`c/${shortParentCid}`}{shortParentCid === comment.shortCid ? " (OP)" : null} +