From b3cee8943cc56780c1f8fd6b88a0c09bc7791685 Mon Sep 17 00:00:00 2001 From: Dustin Brett Date: Fri, 9 Dec 2022 22:02:49 -0800 Subject: [PATCH] One time passive ipfs gateway checks --- utils/ipfs.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/utils/ipfs.ts b/utils/ipfs.ts index 27789c88..06137d2a 100644 --- a/utils/ipfs.ts +++ b/utils/ipfs.ts @@ -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 => ); 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( "",