mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 09:15:33 +03:00
Don't refetch failed unfurls
This commit is contained in:
parent
e2a679e202
commit
7ebd0e7601
1 changed files with 6 additions and 0 deletions
|
@ -1180,11 +1180,15 @@ function isMastodonLinkMaybe(url) {
|
|||
}
|
||||
|
||||
const denylistDomains = /(twitter|github)\.com/i;
|
||||
const failedUnfurls = {};
|
||||
|
||||
function _unfurlMastodonLink(instance, url) {
|
||||
if (denylistDomains.test(url)) {
|
||||
return;
|
||||
}
|
||||
if (failedUnfurls[url]) {
|
||||
return;
|
||||
}
|
||||
const instanceRegex = new RegExp(instance + '/');
|
||||
if (instanceRegex.test(states.unfurledLinks[url]?.url)) {
|
||||
return Promise.resolve(states.unfurledLinks[url]);
|
||||
|
@ -1211,10 +1215,12 @@ function _unfurlMastodonLink(instance, url) {
|
|||
states.unfurledLinks[url] = result;
|
||||
return result;
|
||||
} else {
|
||||
failedUnfurls[url] = true;
|
||||
throw new Error('No results');
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
failedUnfurls[url] = true;
|
||||
console.warn(e);
|
||||
// Silently fail
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue