|
@@ -25,6 +25,7 @@ import UnauthorizedNavigator from '../navigation/UnauthorizedNavigator';
|
|
|
import { authStore } from '../libs/auth/AuthStore';
|
|
|
import { API_URL } from '../utils/RequestUtils';
|
|
|
import {reportAxiosError} from '../libs/auth/core'
|
|
|
+import * as Updates from 'expo-updates'
|
|
|
|
|
|
export enum TokenState {
|
|
|
CheckingToken,
|
|
@@ -44,10 +45,32 @@ const Atlas : React.FC = () => {
|
|
|
*/
|
|
|
const [checkingToken, setCheckingToken] = useState<boolean>(true);
|
|
|
const { refreshAccessToken } = useAuth();
|
|
|
+ const [updatesDismissed, setUpdatesDismissed] = useState<boolean>(false)
|
|
|
const [fontsLoaded, error] = useFonts({
|
|
|
RacingSansOne_400Regular
|
|
|
});
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ const timer = setInterval(async () => {
|
|
|
+ const update = await Updates.checkForUpdateAsync()
|
|
|
+ if (update.isAvailable && !updatesDismissed) {
|
|
|
+ Alert.alert('Update Available', 'An update is available. Would you like to update now?', [
|
|
|
+ {"text": "Yes", "onPress": async () => {
|
|
|
+ await Updates.fetchUpdateAsync()
|
|
|
+ await Updates.reloadAsync()
|
|
|
+ }},
|
|
|
+ {"text": "No", "onPress": () => {
|
|
|
+ setUpdatesDismissed(true)
|
|
|
+ Alert.alert('Update Available', 'Update dismissed, you can always revisit it in settings', [
|
|
|
+ {"text": "OK"}
|
|
|
+ ])
|
|
|
+ }}
|
|
|
+ ])
|
|
|
+ }
|
|
|
+ }, 3000)
|
|
|
+ return () => clearInterval(timer)
|
|
|
+ }, [])
|
|
|
+
|
|
|
/**
|
|
|
* Checks if there is an access token available in {@link AuthStore}, then checks if that access token is valid by calling the API.
|
|
|
* If the response is valid, the access token will be stored in memory, otherwise the user will be directed to intro screen.
|