Skip to content

Commit

Permalink
Merge branch 'develop' into feat/initia
Browse files Browse the repository at this point in the history
  • Loading branch information
songwongtp committed Sep 26, 2023
2 parents 850df77 + b6762e3 commit 5c5d429
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#546](https://github.com/alleslabs/celatone-frontend/pull/546) Handle 404 on the current selected chain
- [#540](https://github.com/alleslabs/celatone-frontend/pull/540) Add open proposal configuration
- [#532](https://github.com/alleslabs/celatone-frontend/pull/532) Implement new Amplitude structure
- [#538](https://github.com/alleslabs/celatone-frontend/pull/538) Add empty state in query and execute with json schema
Expand Down
26 changes: 19 additions & 7 deletions src/lib/app-provider/hooks/useNetworkChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ export const useNetworkChange = (
const navigate = useInternalNavigate();

useEffect(() => {
const networkRoute = router.query.network
? getFirstQueryParam(router.query.network, DEFAULT_SUPPORTED_CHAIN_ID)
: router.asPath.split("/")[1];

if (router.isReady || router.pathname === "/404") {
if (router.isReady) {
const networkRoute = getFirstQueryParam(router.query.network);
// Redirect to default chain if there is no network query provided
if (!router.query.network) {
navigate({
Expand All @@ -30,14 +27,29 @@ export const useNetworkChange = (
router.pathname === "/[network]" &&
!SUPPORTED_CHAIN_IDS.includes(networkRoute)
) {
// Redirect to default network 404 if `/invalid_network`
navigate({
pathname: "/",
replace: true,
pathname: "/404",
query: {
network: DEFAULT_SUPPORTED_CHAIN_ID,
},
});
} else if (networkRoute !== networkRef.current) {
networkRef.current = networkRoute;
handleOnChainIdChange(networkRoute);
}
} else if (router.pathname === "/404") {
const networkRoute = router.asPath.split("/")[1];
// Redirect to the current network 404 if `/current_network/random_path`
// If the current network is also invalid, redicrect to default network 404
navigate({
pathname: "/404",
query: {
network: SUPPORTED_CHAIN_IDS.includes(networkRoute)
? networkRoute
: DEFAULT_SUPPORTED_CHAIN_ID,
},
});
}
}, [
handleOnChainIdChange,
Expand Down

1 comment on commit 5c5d429

@vercel
Copy link

@vercel vercel bot commented on 5c5d429 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.