|
@@ -26,6 +26,7 @@ import { authStore } from '../libs/auth/AuthStore';
|
|
|
import { API_URL } from '../utils/RequestUtils';
|
|
|
import {reportAxiosError} from '../libs/auth/core'
|
|
|
import * as Updates from 'expo-updates'
|
|
|
+import { Manifest, UpdateCheckResult } from 'expo-updates';
|
|
|
|
|
|
export enum TokenState {
|
|
|
CheckingToken,
|
|
@@ -45,7 +46,7 @@ const Atlas : React.FC = () => {
|
|
|
*/
|
|
|
const [checkingToken, setCheckingToken] = useState<boolean>(true);
|
|
|
const { refreshAccessToken } = useAuth();
|
|
|
- const [updatesDismissed, setUpdatesDismissed] = useState<boolean>(false)
|
|
|
+ const updateDismissed = useRef<boolean>(false)
|
|
|
const [fontsLoaded, error] = useFonts({
|
|
|
RacingSansOne_400Regular
|
|
|
});
|
|
@@ -53,21 +54,23 @@ const Atlas : React.FC = () => {
|
|
|
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"}
|
|
|
- ])
|
|
|
- }}
|
|
|
- ])
|
|
|
+ if (update.isAvailable && !updateDismissed.current) {
|
|
|
+ updateDismissed.current = true
|
|
|
+ setTimeout(() => {
|
|
|
+ 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": () => {
|
|
|
+ Alert.alert('Update Available', 'Update dismissed, you can always revisit it in settings', [
|
|
|
+ {"text": "OK"}
|
|
|
+ ])
|
|
|
+ }}
|
|
|
+ ])
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
- }, 3000)
|
|
|
+ }, 5000)
|
|
|
return () => clearInterval(timer)
|
|
|
}, [])
|
|
|
|