Atlas.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved
  2. * Unauthorized copying of this file, via any medium is strictly prohibited
  3. * Proprietary and confidential
  4. * Written and maintained by the Click & Push Development team
  5. * <dev@clicknpush.ca>, January 2022
  6. */
  7. import { observer } from 'mobx-react';
  8. import React from 'react';
  9. import { QueryClient } from 'react-query';
  10. import { Loading } from './Loading';
  11. import { useAuth } from '../data/Auth/AuthContext';
  12. import BaseStackNavigator from '../navigation/BaseStackNavigator';
  13. import { Error } from './Error';
  14. import { navigationRef } from '../navigation/RootNavigator';
  15. import { usePermissions } from '../data/PermissionsContext';
  16. export enum TokenState {
  17. CheckingToken,
  18. ValidToken,
  19. InvalidToken
  20. }
  21. const queryClient = new QueryClient();
  22. /**
  23. * Sub-root component of the app. Contains all global providers (NavigationContainer and SafeAreaProvider for React Navigation, QueryClientProvider for react-query) and is responsible for restricting unauthenticated users to the Intro screen by listening to {@link AuthStore}'s accessToken value.
  24. * @component
  25. */
  26. const Atlas : React.FC = () => {
  27. const {authStateLoading} = useAuth()
  28. const {permissionsLoading} = usePermissions()
  29. // useEffect(() => {
  30. // let isMounted = true
  31. // const checkAuthStateOnAccessTokenUpdate = async () => {
  32. // let accessToken = authStore.accessToken
  33. // if (!accessToken) {
  34. // accessToken = await getItemAsync(SECURESTORE_ACCESSTOKEN)
  35. // }
  36. // if (accessToken)
  37. // await checkAuthenticationState({})
  38. // }
  39. // if (isMounted)
  40. // checkAuthStateOnAccessTokenUpdate()
  41. // return () => { isMounted = false }
  42. // }, [])
  43. return (
  44. <>
  45. {authStateLoading || permissionsLoading ? <Loading/> : <BaseStackNavigator />}
  46. </>
  47. );
  48. }
  49. export default observer(Atlas);