Front: settings persistance (#108)
* Front: Add peristance dependencies * Front: Fix Cross-platform persistance * Front: Create Settings Slice * Front: Use Redux State for settings * Front: Check if access token is still valid * Front: Create Language Gate to set correct language at startup * Front: BEtter handling of Access Token validity
This commit is contained in:
+14
-4
@@ -8,6 +8,8 @@ import { NavigationContainer } from '@react-navigation/native';
|
||||
import { useSelector } from './state/Store';
|
||||
import SongLobbyView from './views/SongLobbyView';
|
||||
import { translate } from './i18n/i18n';
|
||||
import { useQuery } from 'react-query';
|
||||
import API from './API';
|
||||
|
||||
const Stack = createNativeStackNavigator();
|
||||
|
||||
@@ -23,12 +25,20 @@ export const publicRoutes = <React.Fragment>
|
||||
</React.Fragment>;
|
||||
|
||||
export const Router = () => {
|
||||
const isAuthentified = useSelector((state) => state.user.accessToken !== undefined)
|
||||
const isAuthentified = useSelector((state) => state.user.accessToken !== undefined);
|
||||
const userProfile = useQuery(['user', 'me'], () => API.getUserInfo(), {
|
||||
enabled: isAuthentified
|
||||
});
|
||||
return (
|
||||
<NavigationContainer>
|
||||
<Stack.Navigator>
|
||||
{isAuthentified ? protectedRoutes : publicRoutes}
|
||||
</Stack.Navigator>
|
||||
{isAuthentified && !userProfile.isError
|
||||
? <Stack.Navigator>
|
||||
{protectedRoutes}
|
||||
</Stack.Navigator>
|
||||
: <Stack.Navigator>
|
||||
{publicRoutes}
|
||||
</Stack.Navigator>
|
||||
}
|
||||
</NavigationContainer>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user