Workflow updating files of btcwallet

This commit is contained in:
RanchiMall Dev 2024-01-18 19:41:01 +00:00
parent e769be382d
commit 1af69f67a6
2 changed files with 40 additions and 18 deletions

View File

@ -639,20 +639,21 @@
}) })
getExchangeRate() getExchangeRate()
.then(() => { .then(() => {
selectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc';
showCurrentValue = localStorage.getItem('btc-wallet-show-current-value') === 'true' || false;
setTimeout(() => { setTimeout(() => {
document.getElementById('currency_selector').value = selectedCurrency; document.getElementById('currency_selector').value = selectedCurrency;
document.getElementById('show_current_value').checked = showCurrentValue; if (getRef('show_current_value')) {
getRef('show_current_value').classList.toggle('hidden', selectedCurrency === 'btc') document.getElementById('show_current_value').checked = showCurrentValue;
getRef('show_current_value').classList.toggle('hidden', selectedCurrency === 'btc')
}
}, 100) }, 100)
showCurrentValue = localStorage.getItem('btc-wallet-show-current-value') === 'true' || false;
}) })
.catch(e => { .catch(e => {
selectedCurrency = 'btc'; console.error(e);
getRef('show_current_value').remove();
showCurrentValue = false; showCurrentValue = false;
// console.error(e)
getRef('currency_selector').classList.add('hidden')
}).finally(() => { }).finally(() => {
selectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc';
routeTo(window.location.hash) routeTo(window.location.hash)
setTimeout(() => { setTimeout(() => {
getRef('loading_page').animate([ getRef('loading_page').animate([
@ -737,6 +738,16 @@
if (params.query !== query) if (params.query !== query)
getRef('search_query_input').value = params.query; getRef('search_query_input').value = params.query;
render.queryResult(params.query) render.queryResult(params.query)
if (!params.currency && selectedCurrency !== 'btc' && !location.hash.includes(selectedCurrency)) {
history.replaceState(null, null, `${location.hash}&currency=${selectedCurrency}`)
}
if (params.currency && params.currency !== selectedCurrency) {
selectedCurrency = params.currency
document.getElementById('currency_selector').value = selectedCurrency;
document.querySelectorAll('.currency-symbol').forEach(el => el.innerHTML = currencyIcons[selectedCurrency])
if (getRef('show_current_value'))
getRef('show_current_value').classList.toggle('hidden', selectedCurrency === 'btc')
}
} }
break; break;
case 'convert': case 'convert':
@ -1304,7 +1315,8 @@
} else { } else {
showCurrentValue = true; showCurrentValue = true;
localStorage.setItem('btc-wallet-show-current-value', showCurrentValue); localStorage.setItem('btc-wallet-show-current-value', showCurrentValue);
document.getElementById('show_current_value').checked = showCurrentValue; if (getRef('show_current_value'))
getRef('show_current_value').checked = showCurrentValue;
notify('Could not fetch historic price data. Showing current value instead', 'error') notify('Could not fetch historic price data. Showing current value instead', 'error')
return [] return []
} }
@ -1379,8 +1391,9 @@
const isUnconfirmed = block < 0 || block === null || block === undefined; const isUnconfirmed = block < 0 || block === null || block === undefined;
let transactionAmount = 0; let transactionAmount = 0;
if (outputs.length > 1) { if (outputs.length > 1) {
let isSelfTransaction = outputs.length === 2 && outputs[0].address === outputs[1].address;
transactionAmount = outputs.reduce((acc, { address, value }) => { transactionAmount = outputs.reduce((acc, { address, value }) => {
if (inputs.find(input => input.address === address)) return acc; if (!isSelfTransaction && inputs.find(input => input.address === address)) return acc;
return acc + value; return acc + value;
}, 0); }, 0);
} else { } else {
@ -1595,7 +1608,15 @@
let previouslySelectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc'; let previouslySelectedCurrency = localStorage.getItem('btc-wallet-currency') || 'btc';
getRef('currency_selector').addEventListener('change', e => { getRef('currency_selector').addEventListener('change', e => {
selectedCurrency = e.target.value; selectedCurrency = e.target.value;
getRef('show_current_value').classList.toggle('hidden', selectedCurrency === 'btc') if (pagesData.lastPage === 'check_details') {
if (location.hash.includes('currency')) {
history.replaceState(null, null, `${location.hash.split('&')[0]}&currency=${selectedCurrency}`)
} else {
history.replaceState(null, null, `${location.hash}&currency=${selectedCurrency}`)
}
}
if (getRef('show_current_value'))
getRef('show_current_value').classList.toggle('hidden', selectedCurrency === 'btc')
localStorage.setItem('btc-wallet-currency', selectedCurrency); localStorage.setItem('btc-wallet-currency', selectedCurrency);
document.querySelectorAll('.currency-symbol').forEach(el => el.innerHTML = currencyIcons[selectedCurrency]) document.querySelectorAll('.currency-symbol').forEach(el => el.innerHTML = currencyIcons[selectedCurrency])
document.querySelectorAll('transaction-card').forEach(el => el.render()) document.querySelectorAll('transaction-card').forEach(el => el.render())
@ -2290,6 +2311,7 @@
buttonLoader(document.getElementById('increase_fee'), false) buttonLoader(document.getElementById('increase_fee'), false)
} }
} }
// current exchange rate is not available then switch to historic price
</script> </script>
</body> </body>

File diff suppressed because one or more lines are too long