mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 09:29:29 +01:00
fix net state not being right on startup
This commit is contained in:
parent
5af187ba48
commit
46eb293f98
@ -35,6 +35,7 @@ const rebuildQueue = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let serviceCreated = false
|
let serviceCreated = false
|
||||||
|
|
||||||
const createService = async () => {
|
const createService = async () => {
|
||||||
useStore.subscribe(
|
useStore.subscribe(
|
||||||
(currentTrack?: TrackExt) => {
|
(currentTrack?: TrackExt) => {
|
||||||
@ -46,6 +47,10 @@ const createService = async () => {
|
|||||||
(prev, next) => prev?.id === next?.id,
|
(prev, next) => prev?.id === next?.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
NetInfo.fetch().then(state => {
|
||||||
|
setNetState(state.type === NetInfoStateType.cellular ? 'mobile' : 'wifi')
|
||||||
|
})
|
||||||
|
|
||||||
NetInfo.addEventListener(state => {
|
NetInfo.addEventListener(state => {
|
||||||
const currentType = useStore.getState().netState
|
const currentType = useStore.getState().netState
|
||||||
const newType = state.type === NetInfoStateType.cellular ? 'mobile' : 'wifi'
|
const newType = state.type === NetInfoStateType.cellular ? 'mobile' : 'wifi'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user