mirror of
https://github.com/nileshtrivedi/better
synced 2024-12-28 06:00:37 +01:00
fix: failure recovery even if one or more sources fail
This commit is contained in:
parent
4489a30e50
commit
3400d14c79
@ -14,14 +14,14 @@ chrome.runtime.onStartup.addListener(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function fetchAllLists(listUrls) {
|
function fetchAllLists(listUrls) {
|
||||||
var promises = listUrls.map((listUrl) =>
|
var promises = listUrls.map(
|
||||||
fetch(listUrl)
|
(listUrl) => fetch(listUrl).then((resp) => resp.json())
|
||||||
.then((resp) => resp.json())
|
// .catch((e) => console.log("List errored out", e))
|
||||||
.catch((e) => console.log("List errored out", e))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Promise.all(promises).then((results) => {
|
// wait for all requests to complete, ignore errors
|
||||||
BETTER_ALTERNATIVES = results;
|
Promise.all(promises.map((p) => p.catch((e) => null))).then((results) => {
|
||||||
|
BETTER_ALTERNATIVES = results.filter((item) => item != null);
|
||||||
chrome.storage.local.set({ betterSourceData: results }, function () {
|
chrome.storage.local.set({ betterSourceData: results }, function () {
|
||||||
console.log("Set betterSource");
|
console.log("Set betterSource");
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user