Skip to content

Commit

Permalink
ObscuroScan: load eth price on init (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Oct 27, 2023
1 parent 06e56bd commit bddbf71
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tools/obscuroscan_v2/frontend/src/lib/config.dev.js
Original file line number Diff line number Diff line change
@@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion tools/obscuroscan_v2/frontend/src/lib/config.js
Original file line number Diff line number Diff line change
@@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion tools/obscuroscan_v2/frontend/src/lib/config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions tools/obscuroscan_v2/frontend/src/lib/poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tools/obscuroscan_v2/frontend/src/stores/priceStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const usePriceStore = defineStore({
poller: new Poller(() => {
const store = usePriceStore();
store.fetch();
}, 60*Config.pollingInterval)
}, Config.pricePollingInterval)
}),
actions: {
async fetch() {
Expand All @@ -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);
}
Expand Down

0 comments on commit bddbf71

Please sign in to comment.