mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-13 05:38:47 +01:00
18 lines
497 B
React
18 lines
497 B
React
|
|
import { useEffect } from 'react'
|
||
|
|
import { useDispatch } from 'react-redux'
|
||
|
|
import subsonic from '../subsonic'
|
||
|
|
import { scanStatusUpdate } from '../actions'
|
||
|
|
|
||
|
|
export const useInitialScanStatus = () => {
|
||
|
|
const dispatch = useDispatch()
|
||
|
|
useEffect(() => {
|
||
|
|
subsonic
|
||
|
|
.getScanStatus()
|
||
|
|
.then((resp) => resp.json['subsonic-response'])
|
||
|
|
.then((data) => {
|
||
|
|
if (data.status === 'ok') {
|
||
|
|
dispatch(scanStatusUpdate(data.scanStatus))
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}, [dispatch])
|
||
|
|
}
|