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

wappsto-blanket

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wappsto-blanket - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

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

import { getSession } from 'wappsto-redux/selectors/session';
import schemas from 'wappsto-redux/util/schemas';
import { ITEMS_PER_SLICE } from '../util';

@@ -15,6 +16,7 @@ import querystring from 'query-string';

const uniqIds = [...new Set(ids)];
const typeKey = schemas.getSchemaTree(type).name;
let missingIds;
if (useCache && state.entities[type+'s']) {
missingIds = uniqIds.filter(id => !state.entities[type+'s'][id]);
if (useCache && state.entities[typeKey]) {
missingIds = uniqIds.filter(id => !state.entities[typeKey][id]);
} else {

@@ -50,5 +52,5 @@ missingIds = uniqIds;

const cachedResults = state.entities[type+'s'];
const cachedResults = state.entities[typeKey];
if (useCache && cachedResults) {
const cachedIds = uniqIds.filter(id => state.entities[type+'s'][id]);
const cachedIds = uniqIds.filter(id => state.entities[typeKey][id]);
cachedIds.forEach((e) => {

@@ -55,0 +57,0 @@ const item = cachedResults[e];

@@ -59,5 +59,5 @@ import { useState, useEffect, useRef } from 'react';

const getPageCount = ({ store, url, requestsRef, resetCache, useCache }) => {
const getPageCount = ({ store, url, requestsRef, resetCache, useCache, sessionObj }) => {
const state = store.getState();
const session = getSession(state);
const session = sessionObj || getSession(state);

@@ -78,5 +78,5 @@ if(resetCache){

const getItems = ({ store, url, query, pageSize, page, requestsRef, resetCache, useCache }) => {
const getItems = ({ store, url, query, pageSize, page, requestsRef, resetCache, useCache, sessionObj }) => {
const state = store.getState();
const session = getSession(state);
const session = sessionObj || getSession(state);
const offset = (page - 1) * pageSize;

@@ -105,3 +105,3 @@

const usePagination = ({ url, query, page: pageNo=1, pageSize=MAX_PER_PAGE, useCache=true }) => {
const usePagination = ({ url, query, page: pageNo=1, pageSize=MAX_PER_PAGE, useCache=true, session }) => {
const store = useStore();

@@ -117,2 +117,5 @@ const [status, setStatus] = useState();

const start = (currentPage=page, resetCache) => {
if (!url) {
return;
}
requestsRef.current = { items: { status: STATUS.pending }, count: { status: STATUS.pending } };

@@ -122,4 +125,7 @@ mounted.current = true;

const promise1 = getPageCount({ store, url, requestsRef, resetCache, useCache });
const { promise: promise2, cacheUrl } = getItems({ store, url, query, pageSize, page: currentPage, requestsRef, resetCache, useCache });
const sessionObj = session ? { meta: { id: session, type: 'session' } } : undefined;
const promise1 = getPageCount({ store, url, requestsRef, resetCache, useCache, sessionObj });
const { promise: promise2, cacheUrl } = getItems({
store, url, query, pageSize, page: currentPage, requestsRef, resetCache, useCache, sessionObj
});

@@ -172,4 +178,4 @@ Promise.all([promise1, promise2]).then(([resCount, resItems]) => {

setCount(countRes.count);
setItems(itemsRes);
setStatus(STATUS.success);
setItems(itemsRes);
}

@@ -176,0 +182,0 @@ }).catch(() => {

{
"name": "wappsto-blanket",
"version": "1.2.1",
"version": "1.2.2",
"description": "",

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

@@ -30,6 +30,9 @@ import { getServiceVersion } from 'wappsto-redux/util/helpers';

const defaultOptions = {
let defaultOptions = {
endPoint: 'websocket',
version: '2.0'
};
export function setDefaultStreamOptions(options){
defaultOptions = options;
}
const subscriptions = {};

@@ -36,0 +39,0 @@ const subscriptionNumber = {};