From 2a91c005a1f4ff671d06638704c665779b9c33ef Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 12 Jul 2024 13:34:57 +0800 Subject: [PATCH] Test fix self-recursive quote posts --- src/utils/states.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/utils/states.js b/src/utils/states.js index d7381a0f..2b80adb7 100644 --- a/src/utils/states.js +++ b/src/utils/states.js @@ -295,6 +295,16 @@ export function unfurlStatus(status, instance) { unfurlMastodonLink(currentInstance, a.href).then((result) => { if (!result) return; if (!sKey) return; + if (result?.id === status.id) { + // Unfurled post is the post itself??? + // Scenario: + // 1. Post with [URL] + // 2. Unfurl [URL], API returns the same post that contains [URL] + // 3. 💥 Recursive quote posts 💥 + // Note: Mastodon search doesn't return posts that contains [URL], it's actually used to *resolve* the URL + // But some non-Mastodon servers, their search API will eventually search posts that contains [URL] and return them + return; + } if (!Array.isArray(states.statusQuotes[sKey])) { states.statusQuotes[sKey] = []; }