File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,33 @@ export function ChainSyncManager() {
9191 const slug = getChainFromId ( chainId ) ?. slug ;
9292
9393 if ( slug !== chainSlug && ! isNavigating . current ) {
94- const [ , ...rest ] = pathname . split ( '/' ) . filter ( Boolean ) ;
95- const newPath = `/${ slug } /${ rest . join ( '/' ) } ` ;
94+ const pathSegments = pathname . split ( '/' ) . filter ( Boolean ) ;
95+
96+ // Map singular detail routes to their plural list routes
97+ const detailToListRouteMap : Record < string , string > = {
98+ task : 'tasks' ,
99+ deal : 'deals' ,
100+ dataset : 'datasets' ,
101+ app : 'apps' ,
102+ workerpool : 'workerpools' ,
103+ address : '' ,
104+ tx : '' ,
105+ search : '' ,
106+ } ;
107+
108+ const detailRoute = pathSegments [ 1 ] ;
109+ const isOnDetailPage =
110+ pathSegments . length >= 3 && detailRoute in detailToListRouteMap ;
111+
112+ let newPath : string ;
113+ if ( isOnDetailPage ) {
114+ const listRoute = detailToListRouteMap [ detailRoute ] ;
115+ newPath = listRoute ? `/${ slug } /${ listRoute } ` : `/${ slug } ` ;
116+ } else {
117+ const [ , ...rest ] = pathSegments ;
118+ newPath = `/${ slug } /${ rest . join ( '/' ) } ` ;
119+ }
120+
96121 isNavigating . current = true ;
97122 const navigationResult = navigate ( { to : newPath , replace : true } ) ;
98123 if ( navigationResult instanceof Promise ) {
You can’t perform that action at this time.
0 commit comments