Skip to content

Commit

Permalink
fix: try to fix infinite switch loop
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed May 17, 2024
1 parent 88a4723 commit f98f400
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/layouts/NetworkLayout/NetworkLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ export const NetworkLayout = ({

if (chain?.id === getChainId(network)) return;

if (!chain?.unsupported) {
switchAndReset(getNetworkName(chain?.id));
if (chain && !chain?.unsupported) {
switchAndReset(getNetworkName(chain.id));
return;
}

Expand Down
4 changes: 3 additions & 1 deletion src/network/useSubsquidNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export function useSubsquidNetwork() {
const queryClient = useQueryClient();

const switchAndReset = (network: NetworkName) => {
if (app == network) return;

changeApp(network);
queryClient.clear();
};
Expand All @@ -35,6 +37,6 @@ export function getChainId(network: NetworkName) {
return network === NetworkName.Mainnet ? arbitrum.id : arbitrumSepolia.id;
}

export function getNetworkName(chainId?: number) {
export function getNetworkName(chainId: number) {
return chainId === arbitrum.id ? NetworkName.Mainnet : NetworkName.Testnet;
}

0 comments on commit f98f400

Please sign in to comment.