From 5970da20ac3d5d302dc3acd4abeb923f8c77bb90 Mon Sep 17 00:00:00 2001 From: RanchiMall Dev Date: Tue, 16 Jan 2024 09:59:24 +0000 Subject: [PATCH] Workflow updating files of btcwallet --- btcwallet/index.html | 24 +++++++++++++++++------- btcwallet/index.min.html | 30 +++++++++++++++--------------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/btcwallet/index.html b/btcwallet/index.html index d80ba3f..b168173 100644 --- a/btcwallet/index.html +++ b/btcwallet/index.html @@ -1274,9 +1274,19 @@ try { if (!dates.length) return []; if (!Array.isArray(dates)) dates = [dates]; + let timeout const datesToFetch = dates.filter(date => !mappedHistoricPrices.has(date)); + const abortController = new AbortController(); + const { signal } = abortController; if (datesToFetch.length) { - const historicPrices = await fetch(`${historicPriceApis.list[historicPriceApis.active]}/price-history?dates=${dates.join()}`).then(res => res.json()) + timeout = setTimeout(() => { + abortController.abort() + throw new Error(`Historic price data is taking longer than usual to load. Historic prices won't be shown`) + }, 8000) + const historicPrices = await fetch(`${historicPriceApis.list[historicPriceApis.active]}/price-history?dates=${dates.join()}`, { + signal + }).then(res => res.json()) + clearTimeout(timeout) historicPrices.forEach(price => { // map historic price to txs // historic price is per day, so we need to find the price for the day of the tx @@ -1292,11 +1302,11 @@ historicPriceApis.active++ return getHistoricPrice(dates) } else { - selectedCurrency = 'btc' - showCurrentValue = false - localStorage.setItem('btc-wallet-currency', selectedCurrency) - localStorage.setItem('btc-wallet-show-current-value', showCurrentValue) - notify('There was an error fetching historic price data. Please try again later.', 'error') + showCurrentValue = true; + localStorage.setItem('btc-wallet-show-current-value', showCurrentValue); + document.getElementById('show_current_value').checked = showCurrentValue; + notify('Could not fetch historic price data. Showing current value instead', 'error') + return [] } } } @@ -1323,7 +1333,7 @@ // render transactions if (txs.length) { const dates = txs.map(tx => toYDM(tx.time)) - await getHistoricPrice(dates) + await getHistoricPrice(dates); txs.forEach(tx => { const historicPrice = mappedHistoricPrices.get(toYDM(tx.time)) if (historicPrice) { diff --git a/btcwallet/index.min.html b/btcwallet/index.min.html index dd49312..b061a4d 100644 --- a/btcwallet/index.min.html +++ b/btcwallet/index.min.html @@ -1,5 +1,5 @@ - Bitcoin Wallet
Getting Bitcoin Wallet ready
Bitcoin Web Wallet logo
RanchiMall

Bitcoin Wallet

BTC INR USD

Keep your keys safe!

Don't share with anyone. The private key cannot be recovered if lost.

Did you forget your BTC address?

If you have your private key, enter it here and recover your BTC address.