wappsto-blanket
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -5,3 +5,2 @@ import { useState, useEffect, useCallback, useRef, useMemo } from 'react'; | ||
import { setItem } from 'wappsto-redux/actions/items'; | ||
import { makeRequest } from 'wappsto-redux/actions/request'; | ||
@@ -105,8 +104,8 @@ import { makeEntitiesSelector } from 'wappsto-redux/selectors/entities'; | ||
const savedIds = useSelector(state => getSavedIdsItem(state, idsItemName)) || empty; | ||
const requestId = requestIdCache[requestIdName]; | ||
const { request, setRequestId } = useRequest(); | ||
const cachedRequestId = requestIdCache[requestIdName]; | ||
const { request, requestId, setRequestId, send } = useRequest(); | ||
if(requestId && (!request || request.id !== requestId)){ | ||
setRequestId(requestId); | ||
} if(!requestId && customRequest.status !== 'pending'){ | ||
if(cachedRequestId && requestId !== cachedRequestId){ | ||
setRequestId(cachedRequestId); | ||
} if(!cachedRequestId && customRequest.status !== 'pending'){ | ||
setCustomRequest({ status: 'pending', options: { query: props.query } }); | ||
@@ -149,7 +148,10 @@ } | ||
setCustomRequest({ status: 'pending', options: options }); | ||
const crid = dispatch(makeRequest('GET', propsData.url, null, options)); | ||
setRequestId(crid); | ||
const crid = send({ | ||
method: 'GET', | ||
url: propsData.url, | ||
...options | ||
}); | ||
requestIdCache[requestIdName] = crid; | ||
} | ||
}, [propsData.url, dispatch, requestIdName, setRequestId]); | ||
}, [propsData.url, requestIdName, send]); | ||
@@ -169,6 +171,6 @@ const refresh = useCallback((reset) => { | ||
useEffect(() => { | ||
if(!requestId || (request && request.status === 'error')){ | ||
if(!cachedRequestId || (savedIds === empty && !request) || (request && request.status === 'error')){ | ||
refresh(props.reset); | ||
} else { | ||
setRequestId(requestId); | ||
} else if(cachedRequestId !== requestId){ | ||
setRequestId(cachedRequestId); | ||
} | ||
@@ -175,0 +177,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps |
@@ -20,3 +20,3 @@ import { useMemo, useState, useCallback } from 'react'; | ||
dispatch(removeStoreRequest(requestId)); | ||
}, [requestId]); | ||
}, [dispatch, requestId]); | ||
@@ -23,0 +23,0 @@ return { request, requestId, setRequestId, send, removeRequest }; |
{ | ||
"name": "wappsto-blanket", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -133,3 +133,3 @@ import { getServiceVersion } from 'wappsto-redux/util/helpers'; | ||
return false; | ||
} else if (typeof(left) === "object") { | ||
} else if (typeof(left) === 'object') { | ||
if (!matchObject(left, right)) { | ||
@@ -160,3 +160,3 @@ return false; | ||
} else { | ||
for(let i = 0; i < arr1.length; i ++){ | ||
for(let i = 0; i < arr1.length; i++){ | ||
if(arr2.indexOf(arr1[i]) === -1){ | ||
@@ -163,0 +163,0 @@ return false; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28235
846