Skip to content

Commit

Permalink
explorer: link network select to appStore
Browse files Browse the repository at this point in the history
  • Loading branch information
deuch13 committed May 14, 2024
1 parent a46fd0b commit 4bed70f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ exports[`Navbar > renders the Navbar component 1`] = `
<option
value="nodes.dusk.network"
>
testnet
Testnet
</option>
<option
value="devnet.nodes.dusk.network"
>
devnet
Devnet
</option>
Expand Down
1 change: 1 addition & 0 deletions explorer/src/lib/components/navbar/Navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

.dusk-navbar__menu--network {
order: 3;
text-transform: uppercase;
}

.dusk-navbar__menu--network select {
Expand Down
28 changes: 16 additions & 12 deletions explorer/src/lib/components/navbar/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { Button, NavList, Select } from "$lib/dusk/components";
import { AppAnchor, AppImage, SearchNotification } from "$lib/components";
import { SearchField } from "$lib/containers";
import { appStore } from "$lib/stores";
import "./Navbar.css";
Expand Down Expand Up @@ -36,17 +37,6 @@
},
];
const networks = [
{
label: "testnet",
value: `${import.meta.env.VITE_DUSK_TESTNET_NODE}`,
},
{
label: "devnet",
value: `${import.meta.env.VITE_DUSK_DEVNET_NODE}`,
},
];
const dispatch = createEventDispatcher();
async function createEmptySpace() {
Expand All @@ -56,10 +46,20 @@
)[0]?.clientHeight;
}
/**
* @param {Event} e
*/
function handleChange(e) {
// @ts-ignore
appStore.setNetwork(e.target.value);
}
afterNavigate(() => {
hidden = true;
showSearchNotification = false;
});
$: ({ networks } = $appStore);
</script>
<nav
Expand Down Expand Up @@ -91,7 +91,11 @@
class:dusk-navbar__menu--hidden={hidden}
id="dusk-navbar-menu"
>
<Select className="dusk-navbar__menu--network" options={networks} />
<Select
className="dusk-navbar__menu--network"
on:change={handleChange}
options={networks}
/>
<NavList className="dusk-navbar__menu--links" {navigation} />
<div class="dusk-navbar__menu--search">
<SearchField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
STATS_FETCH_INTERVAL
);
onNetworkChange(pollingStatsDataStore.start);
onNetworkChange((network) => {
pollingStatsDataStore.stop();
pollingStatsDataStore.start(network);
});
onNetworkChange(getNodeLocations);
onNetworkChange(getMarketData);
Expand Down
7 changes: 5 additions & 2 deletions explorer/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
$appStore.fetchInterval
);
onNetworkChange(pollingDataStore.start);
$: ({ data, error, isLoading } = $pollingDataStore);
onNetworkChange((network) => {
pollingDataStore.stop();
pollingDataStore.start(network);
});
</script>

<section class="chain-info">
Expand Down

0 comments on commit 4bed70f

Please sign in to comment.