From ce610fbea5471bf1b199f5663f4b59052f662709 Mon Sep 17 00:00:00 2001 From: recanman <29310982+recanman@users.noreply.github.com> Date: Sat, 5 Oct 2024 00:01:41 -0700 Subject: [PATCH] feat: make config clear and add fetch interval config --- src/js/main.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/js/main.js b/src/js/main.js index 9f99bd2..67758ad 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -3,6 +3,14 @@ import '../css/custom.css'; import Tooltip from 'bootstrap/js/dist/tooltip'; +///// +let inactivityTimeout = 30; // in seconds +let fetchInterval = 30; // in seconds +///// + +inactivityTimeout = inactivityTimeout * 1000; +fetchInterval = fetchInterval * 1000; + const tooltipTriggerList = Array.from(document.querySelectorAll('[data-toggle="tooltip"]')); const tooltipList = tooltipTriggerList.map(tooltipTriggerEl => new Tooltip(tooltipTriggerEl, { placement: 'top' })); console.log(tooltipList); @@ -14,13 +22,12 @@ const runConvert = () => lastModifiedField === 'xmr' ? xmrConvert() : fiatConvert(); let updateInterval -const startFetching = () => updateInterval = setInterval(fetchUpdatedExchangeRates, 5000); +const startFetching = () => updateInterval = setInterval(fetchUpdatedExchangeRates, fetchInterval); const stopFetching = () => { clearInterval(updateInterval) updateInterval = null; }; -const inactivityTimeout = 30 * 1000; // 30 seconds let lastActivity = Date.now() const resetActivity = () => lastActivity = Date.now()