One time passive ipfs gateway checks

This commit is contained in:
Dustin Brett
2022-12-09 22:02:49 -08:00
parent 61cc04dfc7
commit b3cee8943c

View File

@@ -2,6 +2,7 @@ import {
HIGH_PRIORITY_REQUEST,
IPFS_GATEWAY_URLS,
MILLISECONDS_IN_SECOND,
ONE_TIME_PASSIVE_EVENT,
} from "utils/constants";
let IPFS_GATEWAY_URL = "";
@@ -14,14 +15,22 @@ const isIpfsGatewayAvailable = (gatewayUrl: string): Promise<boolean> =>
);
const img = new Image();
img.addEventListener("load", () => {
window.clearTimeout(timeoutId);
resolve(true);
});
img.addEventListener("error", () => {
window.clearTimeout(timeoutId);
resolve(false);
});
img.addEventListener(
"load",
() => {
window.clearTimeout(timeoutId);
resolve(true);
},
ONE_TIME_PASSIVE_EVENT
);
img.addEventListener(
"error",
() => {
window.clearTimeout(timeoutId);
resolve(false);
},
ONE_TIME_PASSIVE_EVENT
);
img.src = `${gatewayUrl.replace(
"<CID>",