Make card aware of self-reference
Prevent unfurl if self-referential
This commit is contained in:
parent
ccecc16a2c
commit
a2189bf44b
|
@ -1652,15 +1652,19 @@ function Status({
|
||||||
</MultipleMediaFigure>
|
</MultipleMediaFigure>
|
||||||
)}
|
)}
|
||||||
{!!card &&
|
{!!card &&
|
||||||
card?.url !== status.url &&
|
|
||||||
card?.url !== status.uri &&
|
|
||||||
/^https/i.test(card?.url) &&
|
/^https/i.test(card?.url) &&
|
||||||
!sensitive &&
|
!sensitive &&
|
||||||
!spoilerText &&
|
!spoilerText &&
|
||||||
!poll &&
|
!poll &&
|
||||||
!mediaAttachments.length &&
|
!mediaAttachments.length &&
|
||||||
!snapStates.statusQuotes[sKey] && (
|
!snapStates.statusQuotes[sKey] && (
|
||||||
<Card card={card} instance={currentInstance} />
|
<Card
|
||||||
|
card={card}
|
||||||
|
selfReferential={
|
||||||
|
card?.url === status.url || card?.url === status.uri
|
||||||
|
}
|
||||||
|
instance={currentInstance}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{!isSizeLarge && showCommentCount && (
|
{!isSizeLarge && showCommentCount && (
|
||||||
|
@ -1850,7 +1854,7 @@ function MultipleMediaFigure(props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Card({ card, instance }) {
|
function Card({ card, selfReferential, instance }) {
|
||||||
const snapStates = useSnapshot(states);
|
const snapStates = useSnapshot(states);
|
||||||
const {
|
const {
|
||||||
blurhash,
|
blurhash,
|
||||||
|
@ -1886,7 +1890,7 @@ function Card({ card, instance }) {
|
||||||
const [cardStatusURL, setCardStatusURL] = useState(null);
|
const [cardStatusURL, setCardStatusURL] = useState(null);
|
||||||
// const [cardStatusID, setCardStatusID] = useState(null);
|
// const [cardStatusID, setCardStatusID] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasText && image && isMastodonLinkMaybe(url)) {
|
if (hasText && image && !selfReferential && isMastodonLinkMaybe(url)) {
|
||||||
unfurlMastodonLink(instance, url).then((result) => {
|
unfurlMastodonLink(instance, url).then((result) => {
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
const { id, url } = result;
|
const { id, url } = result;
|
||||||
|
@ -1901,7 +1905,7 @@ function Card({ card, instance }) {
|
||||||
// })();
|
// })();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [hasText, image]);
|
}, [hasText, image, selfReferential]);
|
||||||
|
|
||||||
// if (cardStatusID) {
|
// if (cardStatusID) {
|
||||||
// return (
|
// return (
|
||||||
|
|
Loading…
Reference in a new issue