@fto-consult/expo-ui 2.34.2 → 2.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.34.2",
3
+ "version": "2.34.3",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/App.js CHANGED
@@ -107,7 +107,7 @@ export default function getIndex(options){
107
107
  const date = screensRef.current[screen];
108
108
  const diff = new Date().getTime() - date.getTime();
109
109
  const timeout = defaultNumber(appConfig.get("swrRefreshTimeout"),SWR_REFRESH_TIMEOUT)
110
- //console.log(diff,"is diff and ",date.toFormat("HH:MM:ss"),screensRef,screen);
110
+ screensRef.current[screen] = new Date();
111
111
  return diff >= timeout ? true : false;
112
112
  },
113
113
  initFocus(callback) {
@@ -49,7 +49,7 @@ export const setSessionData = (key,value)=>{
49
49
 
50
50
 
51
51
 
52
- export const timeout = 5000*60//*60;
52
+ export const timeout = 5000*60;//5 minutes
53
53
  /***@see : https://swr.vercel.app/docs/api */
54
54
 
55
55
  export const getSWROptions = ()=>{
@@ -170,11 +170,13 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
170
170
  const canHandleLimit = handleQueryLimit !== false ? true : false;
171
171
  const limitRef = React.useRef(!canHandleLimit ?0 : defaultNumber(getSessionData("limit"),500));
172
172
  const isInitializedRef = React.useRef(false);
173
- testID = defaultStr(testID,"RNSWRDatagridComponent")
174
- const {error, isValidating,isLoading,refresh} = useSWR(fetchPath,{
173
+ testID = defaultStr(testID,"RNSWRDatagridComponent");
174
+ const isLoadingRef = React.useRef(true);
175
+ const {error, isValidating,isLoading:customIsLoading,refresh} = useSWR(fetchPath,{
175
176
  fetcher : (url,opts)=>{
176
177
  if(!isInitializedRef.current) {
177
178
  isFetchingRef.current = false;
179
+ isLoadingRef.current = false;
178
180
  return;
179
181
  }
180
182
  opts = extendObj({},opts,fetchOptionsRef.current);
@@ -206,6 +208,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
206
208
  url = setQueryParams(url,opts.queryParams);
207
209
  return fetcher(url,opts).then(fetchCB).finally(()=>{
208
210
  isFetchingRef.current = false;
211
+ isLoadingRef.current = false;
209
212
  });
210
213
  }
211
214
  const {url:fUrl,fetcher:cFetcher,...rest} = getFetcherOptions(url,opts);
@@ -219,22 +222,21 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
219
222
  ...defaultObj(appConfig.swr),
220
223
  },
221
224
  });
225
+ const isLoading = isLoadingRef.current && customIsLoading || false;
222
226
  React.useEffect(()=>{
223
227
  innerRef.current && innerRef.current.setIsLoading && innerRef.current.setIsLoading(isLoading);
224
228
  },[isLoading])
225
229
  React.useEffect(()=>{
226
230
  const cb = refreshCBRef.current;
227
231
  refreshCBRef.current = null;
228
- if(!isValidating && !isLoading && typeof cb =='function'){
232
+ if(!isValidating && !customIsLoading && typeof cb =='function'){
229
233
  cb();
230
234
  }
231
- },[isValidating,isLoading])
235
+ },[isValidating,customIsLoading])
232
236
  const doRefresh = (showProgress)=>{
233
237
  showProgressRef.current = showProgress ? typeof showProgress ==='boolean' : false;
234
238
  if(isFetchingRef.current) return;
235
- refreshCBRef.current = ()=>{
236
- //showProgressRef.current = false;
237
- };
239
+ isLoadingRef.current = true;
238
240
  refresh();
239
241
  }
240
242
  const canPaginate = ()=>{
@@ -272,7 +274,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
272
274
  ///si le nombre total d'élements est inférieur au nombre limite alors le trie peut être fait localement
273
275
  return totalRef.current > limitRef.current && true || false;
274
276
  }
275
- const loading = (isLoading|| isValidating);
277
+ const loading = (isLoadingRef.current && (isLoading|| isValidating));
276
278
  const pointerEvents = loading ?"node" : "auto";
277
279
  const itLimits = [{
278
280
  text : "Limite nbre elts par page",