mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 16:58:47 +01:00
Prioritise local instance unfurl over remote
This commit is contained in:
parent
39bcb01894
commit
e13a2feec8
1 changed files with 12 additions and 3 deletions
|
@ -2364,9 +2364,18 @@ function _unfurlMastodonLink(instance, url) {
|
|||
}
|
||||
|
||||
if (remoteInstanceFetch) {
|
||||
return Promise.any([remoteInstanceFetch, mastoSearchFetch])
|
||||
.then(handleFulfill)
|
||||
.catch(handleCatch);
|
||||
// return Promise.any([remoteInstanceFetch, mastoSearchFetch])
|
||||
// .then(handleFulfill)
|
||||
// .catch(handleCatch);
|
||||
// If mastoSearchFetch is fulfilled within 3s, return it, else return remoteInstanceFetch
|
||||
const finalPromise = Promise.race([
|
||||
mastoSearchFetch,
|
||||
new Promise((resolve, reject) => setTimeout(reject, 3000)),
|
||||
]).catch(() => {
|
||||
// If remoteInstanceFetch is fullfilled, return it, else return mastoSearchFetch
|
||||
return remoteInstanceFetch.catch(() => mastoSearchFetch);
|
||||
});
|
||||
return finalPromise.then(handleFulfill).catch(handleCatch);
|
||||
} else {
|
||||
return mastoSearchFetch.then(handleFulfill).catch(handleCatch);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue