Skip to content

Commit

Permalink
Fix network-store load calls order (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
zerts authored Sep 9, 2024
1 parent 19b7dd1 commit 1bbb374
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/networks/networks-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type OtherNetworkData = {
};

export class NetworksStore extends Store<State> {
private isReady = false;
private networkConfigs: NetworkConfig[] = [];
private customNetworkConfigs: NetworkConfig[] = [];
private loaderPromises: Record<string, Promise<Networks>> = {};
Expand Down Expand Up @@ -152,6 +153,9 @@ export class NetworksStore extends Store<State> {
}

private async fetchNetworkById(chainId: ChainId) {
if (!this.isReady) {
await this.load();
}
const shouldUpdateNetworksInfo = this.getState()
.networks?.getNetworks()
.every((network) => Networks.getChainId(network) !== chainId);
Expand Down Expand Up @@ -186,6 +190,7 @@ export class NetworksStore extends Store<State> {
testnetMode: this.testnetMode,
}).finally(() => {
delete this.loaderPromises[key];
this.isReady = true;
});
}
return this.loaderPromises[key];
Expand Down

0 comments on commit 1bbb374

Please sign in to comment.