mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01: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 denylistDomains = /(twitter|github)\.com/i;
|
||||||
|
const failedUnfurls = {};
|
||||||
|
|
||||||
function _unfurlMastodonLink(instance, url) {
|
function _unfurlMastodonLink(instance, url) {
|
||||||
if (denylistDomains.test(url)) {
|
if (denylistDomains.test(url)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (failedUnfurls[url]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const instanceRegex = new RegExp(instance + '/');
|
const instanceRegex = new RegExp(instance + '/');
|
||||||
if (instanceRegex.test(states.unfurledLinks[url]?.url)) {
|
if (instanceRegex.test(states.unfurledLinks[url]?.url)) {
|
||||||
return Promise.resolve(states.unfurledLinks[url]);
|
return Promise.resolve(states.unfurledLinks[url]);
|
||||||
|
@ -1211,10 +1215,12 @@ function _unfurlMastodonLink(instance, url) {
|
||||||
states.unfurledLinks[url] = result;
|
states.unfurledLinks[url] = result;
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
failedUnfurls[url] = true;
|
||||||
throw new Error('No results');
|
throw new Error('No results');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
failedUnfurls[url] = true;
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
// Silently fail
|
// Silently fail
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue