-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
38 lines (31 loc) · 1.03 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
import React, { useEffect, useState } from 'react';
import { AppState } from 'react-native';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/lib/integration/react';
import { store, persistor } from './src/reducers/store';
import Routes from './src/routes';
import TrackPlayer from 'react-native-track-player';
import TrackPlayerService from './src/modules/player/service/track-player.service';
const App = () => {
const [isPlayerReady, setIsPlayerReady] = useState<boolean>(false);
// TODO: create a loading modal to show while player is not ready
useEffect(() => {
async function run() {
await TrackPlayerService.setup();
setIsPlayerReady(true);
const queue = await TrackPlayer.getQueue();
if (queue.length <= 0) {
await TrackPlayerService.setPlayerTracks();
}
}
run();
}, []);
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Routes/>
</PersistGate>
</Provider>
);
};
export default App;