Skip to content

Commit

Permalink
explorer: call reset method on network change
Browse files Browse the repository at this point in the history
  • Loading branch information
deuch13 committed May 20, 2024
1 parent 824bfc5 commit 6636c09
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions explorer/src/lib/components/navbar/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/**
* @param {Event} e
*/
function handleChange(e) {
function handleNetworkChange(e) {
// @ts-ignore
appStore.setNetwork(e.target.value);
}
Expand Down Expand Up @@ -94,7 +94,7 @@
>
<Select
className="dusk-navbar__menu--network"
on:change={handleChange}
on:change={handleNetworkChange}
options={networks}
/>
<NavList className="dusk-navbar__menu--links" {navigation} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
);
onNetworkChange((network) => {
marketDataStore.getData(network);
marketDataStore.getData();
nodeLocationsStore.reset();
nodeLocationsStore.getData(network);
pollingStatsDataStore.reset();
pollingStatsDataStore.start(network);
});
Expand Down
6 changes: 2 additions & 4 deletions explorer/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
$appStore.fetchInterval
);
onNetworkChange(pollingDataStore.start);
onDestroy(pollingDataStore.stop);
$: ({ data, error, isLoading } = $pollingDataStore);
onNetworkChange((network) => {
pollingDataStore.stop();
pollingDataStore.reset();
pollingDataStore.start(network);
});
onDestroy(pollingDataStore.stop);
</script>

<section class="chain-info">
Expand Down
5 changes: 3 additions & 2 deletions explorer/src/routes/blocks/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
);
$: ({ data, error, isLoading } = $pollingDataStore);
$: ({ network: currentNetwork } = $appStore);
onNetworkChange((network) => {
pollingDataStore.stop();
pollingDataStore.reset();
pollingDataStore.start(network);
});
Expand All @@ -23,7 +24,7 @@

<section id="blocks">
<BlocksCard
on:retry={pollingDataStore.start}
on:retry={() => pollingDataStore.start(currentNetwork)}
blocks={data}
{error}
loading={isLoading}
Expand Down
10 changes: 4 additions & 6 deletions explorer/src/routes/blocks/block/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
import { appStore } from "$lib/stores";
import { createDataStore } from "$lib/dusk/svelte-stores";
import { onNetworkChange } from "$lib/lifecyles";
import { onMount } from "svelte";
const dataStore = createDataStore(duskAPI.getBlock);
const getBlock = () => {
dataStore.getData($appStore.network, $page.url.searchParams.get("id"));
};
onNetworkChange(getBlock);
$: ({ data, error, isLoading } = $dataStore);
onMount(() => {
onNetworkChange(() => {
dataStore.reset();
getBlock();
});
$: ({ data, error, isLoading } = $dataStore);
</script>

<section class="block">
Expand Down
5 changes: 3 additions & 2 deletions explorer/src/routes/transactions/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
);
$: ({ data, error, isLoading } = $pollingDataStore);
$: ({ network: currentNetwork } = $appStore);
onNetworkChange((network) => {
pollingDataStore.stop();
pollingDataStore.reset();
pollingDataStore.start(network);
});
Expand All @@ -23,7 +24,7 @@

<section id="transactions">
<TransactionsCard
on:retry={pollingDataStore.start}
on:retry={() => pollingDataStore.start(currentNetwork)}
txs={data}
{error}
loading={isLoading}
Expand Down
6 changes: 5 additions & 1 deletion explorer/src/routes/transactions/transaction/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
marketStore.getData($appStore.network);
};
onNetworkChange(getTransaction);
onNetworkChange(() => {
dataStore.reset();
payloadStore.reset();
getTransaction();
});
$: ({ data, error, isLoading } = $dataStore);
$: ({ data: payloadData } = $payloadStore);
Expand Down

0 comments on commit 6636c09

Please sign in to comment.