Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wappsto-blanket

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wappsto-blanket - npm Package Compare versions

Comparing version 0.0.27 to 0.1.1

33

hooks/useList.js

@@ -31,2 +31,3 @@ import { useState, useEffect, useCallback, useRef, useMemo } from 'react';

const empty = [];
const requestIdCache = {};
function useList(props){

@@ -98,12 +99,15 @@ const dispatch = useDispatch();

const [ customRequest, setCustomRequest ] = useState({ status: 'pending', options: { query } });
const { request, setRequestId } = useRequest();
const [ customRequest, setCustomRequest ] = useState({ status: 'pending', options: { query: props.query } });
const name = props.name || (propsData.url + JSON.stringify(propsData.query));
const idsItemName = name + '_ids';
const fetchedItemName = name + '_fetched';
const requestIdName = name + '_requestId';
const getSavedIdsItem = useMemo(makeItemSelector, []);
const savedIds = useSelector(state => getSavedIdsItem(state, idsItemName)) || empty;
const getFetchedItem = useMemo(makeItemSelector, []);
const fetched = useSelector(state => getFetchedItem(state, fetchedItemName));
const requestId = requestIdCache[requestIdName];
const { request, setRequestId } = useRequest();
if(requestId && (!request ||request.id !== requestId)){
setRequestId(requestId);
}
const limit = propsData.query.limit;

@@ -116,3 +120,3 @@

if(!fetched
if(!request
|| items.length === 0

@@ -144,5 +148,7 @@ || (request && request.status === 'error')

setCustomRequest({ status: 'pending', options: options });
setRequestId(dispatch(makeRequest('GET', propsData.url, null, options)));
const crid = dispatch(makeRequest('GET', propsData.url, null, options));
setRequestId(crid);
requestIdCache[requestIdName] = crid;
}
}, [dispatch, propsData.url, setRequestId]);
}, [propsData.url, dispatch, requestIdName, setRequestId]);

@@ -162,9 +168,9 @@ const refresh = useCallback((reset) => {

useEffect(() => {
if((!fetched && (!request || request.status !== 'pending')) || (fetched && request && request.status === 'error')){
if(!requestIdCache[requestIdName] || (request && request.status === 'error')){
refresh(props.reset);
} else {
setCustomRequest({ status: 'success' });
}
setRequestId(requestIdCache[requestIdName]);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [propsData.query, props.id, propsData.url, refresh, fetched]);
}, [propsData.query, props.id, propsData.url, refresh]);

@@ -218,5 +224,4 @@ // function updateItemCount

setCustomRequest(request);
} else if(prevRequest && prevRequest.status === 'success' && request.status === 'success' && customRequest.status !== 'success'){
} else if((!prevRequest || prevRequest.status === 'success') && request.status === 'success' && (customRequest.status !== 'success' || customRequest.id !== request.id)){
setCustomRequest(request);
dispatch(setItem(fetchedItemName, true));
}

@@ -223,0 +228,0 @@ }

{
"name": "wappsto-blanket",
"version": "0.0.27",
"version": "0.1.1",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

@@ -107,3 +107,3 @@ import { getServiceVersion } from 'wappsto-redux/util/helpers';

dispatch(closeStream(mainStream, true));
dispatch(updateReduxStream(mainStream, null, null, ws, { subscription: newSubscriptions, name: mainStream, full: options.full || false }));
dispatch(updateReduxStream(mainStream, undefined, undefined, ws, { subscription: newSubscriptions, name: mainStream, full: options.full || false }));
subscriptions.old = subscriptions.new;

@@ -110,0 +110,0 @@ subscriptions.new = null;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc