Compare commits
No commits in common. "1f5999b2d17d1d3569736006b4a5fad923690c0a" and "a50920d70e84c8be20e574d605330e060d23b2cb" have entirely different histories.
1f5999b2d1
...
a50920d70e
@ -1,11 +1,5 @@
|
|||||||
# @warkypublic/zustandsyncstore
|
# @warkypublic/zustandsyncstore
|
||||||
|
|
||||||
## 0.0.8
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- cdcb5c2: Fixed memo of options in GridlerAPIAdaptor
|
|
||||||
|
|
||||||
## 0.0.7
|
## 0.0.7
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@warkypublic/oranguru",
|
"name": "@warkypublic/oranguru",
|
||||||
"author": "Warky Devs",
|
"author": "Warky Devs",
|
||||||
"version": "0.0.8",
|
"version": "0.0.7",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
import type { APIOptions } from '../../utils/types';
|
import type { APIOptions } from '../../utils/types';
|
||||||
|
|
||||||
@ -20,8 +20,7 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
|||||||
s.mounted,
|
s.mounted,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const useAPIQuery: (index: number) => Promise<any> = useCallback(
|
const useAPIQuery: (index: number) => Promise<any> = async (index: number) => {
|
||||||
async (index: number) => {
|
|
||||||
const colSort = getState('colSort');
|
const colSort = getState('colSort');
|
||||||
const pageSize = getState('pageSize');
|
const pageSize = getState('pageSize');
|
||||||
const colFilters = getState('colFilters');
|
const colFilters = getState('colFilters');
|
||||||
@ -68,21 +67,14 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
|||||||
r.controller?.abort?.();
|
r.controller?.abort?.();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (
|
if (_active_requests && currentRequestIndex >= 0 && _active_requests[currentRequestIndex]) {
|
||||||
_active_requests &&
|
|
||||||
currentRequestIndex >= 0 &&
|
|
||||||
_active_requests[currentRequestIndex]
|
|
||||||
) {
|
|
||||||
//console.log(`Already queued ${index}`, index, s._active_requests);
|
//console.log(`Already queued ${index}`, index, s._active_requests);
|
||||||
setState('loadingData', false);
|
setState('loadingData', false);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
await setStateFN('_active_requests', (cv) => [
|
await setStateFN('_active_requests', (cv) => [...(cv ?? []), { controller, page: index }]);
|
||||||
...(cv ?? []),
|
|
||||||
{ controller, page: index },
|
|
||||||
]);
|
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${props.url}?x-limit=${String(pageSize ?? 50)}&x-offset=${String((pageSize ?? 50) * index)}`,
|
`${props.url}?x-limit=${String(pageSize ?? 50)}&x-offset=${String((pageSize ?? 50) * index)}`,
|
||||||
@ -115,12 +107,9 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
|||||||
}
|
}
|
||||||
setState('loadingData', false);
|
setState('loadingData', false);
|
||||||
return [];
|
return [];
|
||||||
},
|
};
|
||||||
[getState, props.authtoken, props.url, props.options, setState, setStateFN, addError]
|
|
||||||
);
|
|
||||||
|
|
||||||
const askAPIRowNumber: (key: string) => Promise<number> = useCallback(
|
const askAPIRowNumber: (key: string) => Promise<number> = async (key: string) => {
|
||||||
async (key: string) => {
|
|
||||||
const colFilters = getState('colFilters');
|
const colFilters = getState('colFilters');
|
||||||
|
|
||||||
//console.log('APIAdaptorGoLangv2', { _active_requests, index, pageSize, props });
|
//console.log('APIAdaptorGoLangv2', { _active_requests, index, pageSize, props });
|
||||||
@ -141,13 +130,6 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.options && props.options.length > 0) {
|
|
||||||
const optionHeaders = GoAPIHeaders(props.options);
|
|
||||||
for (const oh in optionHeaders) {
|
|
||||||
head.set(oh, optionHeaders[oh]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
const res = await fetch(`${props.url}?x-fetch-rownumber=${key}}`, {
|
const res = await fetch(`${props.url}?x-fetch-rownumber=${key}}`, {
|
||||||
@ -164,14 +146,12 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
|||||||
addError(`${res.status} ${res.statusText}`, 'api', props.url);
|
addError(`${res.status} ${res.statusText}`, 'api', props.url);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
};
|
||||||
[props.url, props.authtoken, props.options, getState, addError]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setState('useAPIQuery', useAPIQuery);
|
setState('useAPIQuery', useAPIQuery);
|
||||||
setState('askAPIRowNumber', askAPIRowNumber);
|
setState('askAPIRowNumber', askAPIRowNumber);
|
||||||
}, [props.url, props.authtoken, props.options, mounted, setState]);
|
}, [props.url, props.authtoken, mounted, setState]);
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user