-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
54 lines (43 loc) · 1.69 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, { useEffect, useState } from 'react'
import { StatusBar, LogBox } from 'react-native'
import NetInfo from '@react-native-community/netinfo'
import * as RNFS from 'react-native-fs'
import { AuthProvider } from './src/contexts/auth'
import { ApiCredentialsProvider } from './src/contexts/apiCredentials'
import Routes from './src/routes/index'
import NoInternetConnection from './src/pages/SpotHackPages/NoInternetConnection'
import downloadMachine from './src/SpotHack_Core/DownloadMachine'
const mobile:React.FC = () => {
const [isOnline, setIsOnline] = useState(false)
NetInfo.fetch().then(state => {
setIsOnline((state.isConnected || false) && (state.isInternetReachable || false))
})
useEffect(() => {
LogBox.ignoreLogs([
'react-native-ytdl is out of date! If the latest port is available, update with "npm install react-native-ytdl@latest".',
'react-native-ytdl: miniget: will not use specified encoding since request has already been made. Currently using utf8 encoding.'
])
}, [])
if (!downloadMachine.isFgServiceOn) {
RNFS.readDir(RNFS.CachesDirectoryPath)
.then(foldersOnCache => {
if (foldersOnCache
.some(pathOnCache => (pathOnCache.name === 'musicsVideos' && pathOnCache.isDirectory()))
) {
RNFS.readDir(RNFS.CachesDirectoryPath + '/musicsVideos')
.then(musicsToDelete =>
musicsToDelete.forEach(musicToDelete => RNFS.unlink(musicToDelete.path))
)
}
})
}
return (
<ApiCredentialsProvider>
<AuthProvider>
<StatusBar barStyle={'light-content'} translucent={false} backgroundColor={'#1c5ed6'}/>
{isOnline ? <Routes /> : <NoInternetConnection />}
</ AuthProvider>
</ApiCredentialsProvider>
)
}
export default mobile