Bug fixes

This commit is contained in:
sairaj mote 2023-04-01 03:16:42 +05:30
parent 564bd49768
commit 826cb771e4
3 changed files with 36 additions and 44 deletions

View File

@ -75,39 +75,6 @@
<script src="scripts/chainkyc.js"></script> <script src="scripts/chainkyc.js"></script>
<script> <script>
const { html, render: renderElem } = uhtml; const { html, render: renderElem } = uhtml;
function getFormattedTime(timestamp, format) {
try {
if (String(timestamp).length < 13)
timestamp *= 1000
let [day, month, date, year] = new Date(timestamp).toString().split(' '),
minutes = new Date(timestamp).getMinutes(),
hours = new Date(timestamp).getHours(),
currentTime = new Date().toString().split(' ')
minutes = minutes < 10 ? `0${minutes}` : minutes
let finalHours = ``;
if (hours > 12)
finalHours = `${hours - 12}:${minutes}`
else if (hours === 0)
finalHours = `12:${minutes}`
else
finalHours = `${hours}:${minutes}`
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
switch (format) {
case 'date-only':
return `${month} ${date}, ${year}`;
break;
case 'time-only':
return finalHours;
default:
return `${month} ${date}, ${year} at ${finalHours}`;
}
} catch (e) {
console.error(e);
return timestamp;
}
}
</script> </script>
<script> <script>
router.addRoute('', async state => { router.addRoute('', async state => {

View File

@ -321,7 +321,7 @@
if (getRef('aggregator_private_key').isValid) { if (getRef('aggregator_private_key').isValid) {
floBlockchainAPI.getBalance(address).then(balance => { floBlockchainAPI.getBalance(address).then(balance => {
if (balance < 0.01) { if (balance < 0.01) {
renderElem(getRef('aggregator_balance'), html`Balance: ${balance}FLO. You don't have enough FLO.`); renderElem(getRef('aggregator_balance'), html`Balance: ${balance} FLO. You don't have enough FLO.`);
getRef('aggregator_balance').classList.add('error') getRef('aggregator_balance').classList.add('error')
} else { } else {
renderElem(getRef('aggregator_balance'), html`Balance: ${balance} FLO`); renderElem(getRef('aggregator_balance'), html`Balance: ${balance} FLO`);
@ -454,6 +454,7 @@
}) })
addressesToRevoke.clear() addressesToRevoke.clear()
render.approvedKycs() render.approvedKycs()
clearSelection()
}).catch(e => { }).catch(e => {
notify(e, 'error') notify(e, 'error')
}).finally(() => { }).finally(() => {

View File

@ -64,15 +64,38 @@ const getConfirmation = (title, options = {}) => {
}) })
}) })
} }
// Use when a function needs to be executed after user finishes changes function getFormattedTime(timestamp, format) {
const debounce = (callback, wait) => { try {
let timeoutId = null; if (String(timestamp).length < 13)
return (...args) => { timestamp *= 1000
window.clearTimeout(timeoutId); let [day, month, date, year] = new Date(timestamp).toString().split(' '),
timeoutId = window.setTimeout(() => { minutes = new Date(timestamp).getMinutes(),
callback.apply(null, args); hours = new Date(timestamp).getHours(),
}, wait); currentTime = new Date().toString().split(' ')
};
minutes = minutes < 10 ? `0${minutes}` : minutes
let finalHours = ``;
if (hours > 12)
finalHours = `${hours - 12}:${minutes}`
else if (hours === 0)
finalHours = `12:${minutes}`
else
finalHours = `${hours}:${minutes}`
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
switch (format) {
case 'date-only':
return `${month} ${date}, ${year}`;
break;
case 'time-only':
return finalHours;
default:
return `${month} ${date}, ${year} at ${finalHours}`;
}
} catch (e) {
console.error(e);
return timestamp;
}
} }
class Router { class Router {
@ -158,7 +181,7 @@ function getApprovedAggregators() {
break; break;
case 'REVOKE_AGGREGATOR': case 'REVOKE_AGGREGATOR':
operationData.split(',').forEach(aggregator => { operationData.split(',').forEach(aggregator => {
floGlobals.approvedKycAggregators[floCrypto.toFloID(aggregator)].validTo = time * 1000; delete floGlobals.approvedKycAggregators[floCrypto.toFloID(aggregator)]
}); });
break; break;
default: default:
@ -198,6 +221,7 @@ function getApprovedKycs() {
break; break;
case 'REVOKE_KYC': case 'REVOKE_KYC':
operationData.split(',').forEach(address => { operationData.split(',').forEach(address => {
if (!floGlobals.approvedKyc[address]) return
floGlobals.approvedKyc[address].validTo = time * 1000; floGlobals.approvedKyc[address].validTo = time * 1000;
floGlobals.approvedKyc[address].revokedBy = vin[0].addr; floGlobals.approvedKyc[address].revokedBy = vin[0].addr;
}); });