1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00
This commit is contained in:
Sergio Betanzos 2021-07-15 12:06:01 +02:00
parent 1d5a8f59b3
commit 1f5a73125a
No known key found for this signature in database
GPG Key ID: E3E704F097737136
2 changed files with 5 additions and 6 deletions

View File

@ -16,7 +16,6 @@
import { useReducer, useCallback, useEffect, useRef, ReducerState, ReducerAction } from 'react'
import { fakeDelay } from 'client/utils'
/** @enum {string} Status of request */
const STATUS = {
INIT: 'INIT',
PENDING: 'PENDING',
@ -153,7 +152,7 @@ const useFetch = (request, socket) => {
return fakeDelay(delay).then(() => doFetch(payload, reload))
}, [request])
return { ...state, fetchRequest, STATUS, ACTIONS }
return { ...state, fetchRequest, STATUS }
}
export default useFetch

View File

@ -16,7 +16,6 @@
import { useReducer, useCallback, useEffect, useRef, ReducerState, ReducerAction } from 'react'
import { fakeDelay } from 'client/utils'
/** @enum {string} Status of request */
const STATUS = {
INIT: 'INIT',
PENDING: 'PENDING',
@ -123,7 +122,7 @@ const useFetchAll = () => {
* @param {number} options.delay - Delay to trigger the request
* @returns {Promise} - Returns a promise with responses or error
*/
(requests, options = {}) => {
async (requests, options = {}) => {
const { reload = false, delay = 0 } = options
if (!(Number.isInteger(delay) && delay >= 0)) {
@ -132,10 +131,11 @@ const useFetchAll = () => {
If you're using it as a function, it must also return a number >= 0.`)
}
return fakeDelay(delay).then(() => doFetches(requests, reload))
await fakeDelay(delay)
return await doFetches(requests, reload)
}, [])
return { ...state, fetchRequestAll, STATUS, ACTIONS }
return { ...state, fetchRequestAll, STATUS }
}
export default useFetchAll