diff --git a/tools/obscuroscan_v2/frontend/src/lib/config.dev.js b/tools/obscuroscan_v2/frontend/src/lib/config.dev.js index d3ee7ef092..cf242044b4 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/config.dev.js +++ b/tools/obscuroscan_v2/frontend/src/lib/config.dev.js @@ -1,7 +1,7 @@ class Config { static backendServerAddress = "http://127.0.0.1:43910" static pollingInterval = 1000 - static pricePollingInterval = 10000*10000 + static pricePollingInterval = 60*1000 // 1 minute static version = "dev" } diff --git a/tools/obscuroscan_v2/frontend/src/lib/config.js b/tools/obscuroscan_v2/frontend/src/lib/config.js index d3ee7ef092..cf242044b4 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/config.js +++ b/tools/obscuroscan_v2/frontend/src/lib/config.js @@ -1,7 +1,7 @@ class Config { static backendServerAddress = "http://127.0.0.1:43910" static pollingInterval = 1000 - static pricePollingInterval = 10000*10000 + static pricePollingInterval = 60*1000 // 1 minute static version = "dev" } diff --git a/tools/obscuroscan_v2/frontend/src/lib/config.prod.js b/tools/obscuroscan_v2/frontend/src/lib/config.prod.js index 99f6467308..affe11ac2b 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/config.prod.js +++ b/tools/obscuroscan_v2/frontend/src/lib/config.prod.js @@ -2,7 +2,7 @@ class Config { // VITE_APIHOSTADDRESS should be used as an env var at the prod server static backendServerAddress = import.meta.env.VITE_APIHOSTADDRESS static pollingInterval = 1000 - static pricePollingInterval = 10*this.pollingInterval + static pricePollingInterval = 60*1000 // 1 minute static version = import.meta.env.VITE_FE_VERSION } diff --git a/tools/obscuroscan_v2/frontend/src/lib/poller.js b/tools/obscuroscan_v2/frontend/src/lib/poller.js index 0afac84746..8a758bd94b 100644 --- a/tools/obscuroscan_v2/frontend/src/lib/poller.js +++ b/tools/obscuroscan_v2/frontend/src/lib/poller.js @@ -5,8 +5,10 @@ class Poller { this.timer = null; } + // Start polling - executes the fetchCallback immediately and every interval thereafter start() { this.stop(); // Ensure previous intervals are cleared + this.fetchCallback(); this.timer = setInterval(async () => { await this.fetchCallback(); }, this.interval); diff --git a/tools/obscuroscan_v2/frontend/src/stores/priceStore.js b/tools/obscuroscan_v2/frontend/src/stores/priceStore.js index 7134ff7e1c..60c07a7dc3 100644 --- a/tools/obscuroscan_v2/frontend/src/stores/priceStore.js +++ b/tools/obscuroscan_v2/frontend/src/stores/priceStore.js @@ -9,7 +9,7 @@ export const usePriceStore = defineStore({ poller: new Poller(() => { const store = usePriceStore(); store.fetch(); - }, 60*Config.pollingInterval) + }, Config.pricePollingInterval) }), actions: { async fetch() { @@ -18,7 +18,7 @@ export const usePriceStore = defineStore({ const data = await response.json(); this.ethPriceUSD = data.ethereum.usd; - console.log("Fetched "+this.ethPriceUSD); + console.log("Fetched " + this.ethPriceUSD); } catch (error) { console.error("Failed to fetch count:", error); }