Skip to content

Commit

Permalink
ObscuroScan: load data immediately on init
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel committed Oct 27, 2023
1 parent 06e56bd commit baaa0ab
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tools/obscuroscan_v2/backend/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func parseCLIArgs() *config.Config {
defaultConfig := &config.Config{
NodeHostAddress: "http://erpc.dev-testnet.obscu.ro:80",
ServerAddress: "0.0.0.0:80",
ServerAddress: "0.0.0.0:43910",
LogPath: "obscuroscan_logs.txt",
}

Expand Down
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
6 changes: 3 additions & 3 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,13 +18,13 @@ 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);
}
},

startPolling() {
async startPolling() {
this.poller.start();
},

Expand Down

0 comments on commit baaa0ab

Please sign in to comment.