mirror of
				https://gitlab.nic.cz/turris/reforis/foris-js.git
				synced 2025-11-03 23:00:31 +01:00 
			
		
		
		
	Catch error and sending state in API polling.
This commit is contained in:
		@@ -95,13 +95,13 @@ export {
 | 
			
		||||
 | 
			
		||||
export function useAPIPolling(endpoint, delay = 1000, until) { // delay ms
 | 
			
		||||
    const [state, setState] = useState({ state: API_STATE.INIT });
 | 
			
		||||
    const [getState, get] = useAPIGet(endpoint);
 | 
			
		||||
    const [getResponse, get] = useAPIGet(endpoint);
 | 
			
		||||
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        if (getState.state === API_STATE.SUCCESS) {
 | 
			
		||||
            setState(getState);
 | 
			
		||||
        if (getResponse.state !== API_STATE.INIT) {
 | 
			
		||||
            setState(getResponse);
 | 
			
		||||
        }
 | 
			
		||||
    }, [getState]);
 | 
			
		||||
    }, [getResponse]);
 | 
			
		||||
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        if (until) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user