From 6f430ca0f5bea705dcd41ded674af81a355816ac Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 25 Apr 2023 21:57:12 +0800 Subject: [PATCH] Fix wrong index of QTs for links that are not QTs --- src/components/status.jsx | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index 057fcae8..074db7a8 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -942,25 +942,25 @@ function Status({ }); if (previewMode) return; // Unfurl Mastodon links - dom - .querySelectorAll( + Array.from( + dom.querySelectorAll( 'a[href]:not(.u-url):not(.mention):not(.hashtag)', - ) + ), + ) + .filter((a) => isMastodonLinkMaybe(a.href)) .forEach((a, i) => { - if (isMastodonLinkMaybe(a.href)) { - unfurlMastodonLink(currentInstance, a.href).then( - (result) => { - if (!result) return; - a.removeAttribute('target'); - if (!Array.isArray(states.statusQuotes[sKey])) { - states.statusQuotes[sKey] = []; - } - if (!states.statusQuotes[sKey][i]) { - states.statusQuotes[sKey].splice(i, 0, result); - } - }, - ); - } + unfurlMastodonLink(currentInstance, a.href).then( + (result) => { + if (!result) return; + a.removeAttribute('target'); + if (!Array.isArray(states.statusQuotes[sKey])) { + states.statusQuotes[sKey] = []; + } + if (!states.statusQuotes[sKey][i]) { + states.statusQuotes[sKey].splice(i, 0, result); + } + }, + ); }); }, }), @@ -1946,6 +1946,7 @@ const QuoteStatuses = memo(({ id, instance, level = 0 }) => { return quotes.map((q) => { return (