@@ -35,6 +35,7 @@ import { setLanguage } from '../../actions/preferences';
35
35
import Overlay from '../../../App/components/Overlay' ;
36
36
import ProjectName from './ProjectName' ;
37
37
import CollectionCreate from '../../../User/components/CollectionCreate' ;
38
+ import useWhatPage from '../../hooks/useWhatPage' ;
38
39
39
40
const Nav = styled ( NavBar ) `
40
41
background: ${ prop ( 'MobilePanel.default.background' ) } ;
@@ -203,33 +204,28 @@ const MobileNav = () => {
203
204
204
205
const { t } = useTranslation ( ) ;
205
206
206
- const { pathname } = useLocation ( ) ;
207
207
const editorLink = useSelector ( selectSketchPath ) ;
208
+ const pageName = useWhatPage ( ) ;
208
209
209
210
// TODO: remove the switch and use a props like mobileTitle <Nav layout=“dashboard” mobileTitle={t(‘Login’)} />
210
211
function resolveTitle ( ) {
211
- switch ( pathname ) {
212
- case '/' :
213
- return project . name ;
214
- case '/login' :
212
+ switch ( pageName ) {
213
+ case 'login' :
215
214
return t ( 'LoginView.Login' ) ;
216
- case '/ signup' :
215
+ case 'signup' :
217
216
return t ( 'LoginView.SignUp' ) ;
218
- case '/ account' :
217
+ case 'account' :
219
218
return t ( 'AccountView.Settings' ) ;
220
- case '/p5/sketches' :
221
- case '/p5/collections' :
219
+ case 'examples' :
222
220
return t ( 'Nav.File.Examples' ) ;
223
- case `/${ user . username } /assets` :
224
- case `/${ user . username } /collections` :
225
- case `/${ user . username } /sketches` :
221
+ case 'myStuff' :
226
222
return 'My Stuff' ;
227
223
default :
228
224
return project . name ;
229
225
}
230
226
}
231
227
232
- const title = useMemo ( resolveTitle , [ project , pathname ] ) ;
228
+ const title = useMemo ( resolveTitle , [ pageName ] ) ;
233
229
234
230
const Logo = AsteriskIcon ;
235
231
return (
0 commit comments