@tanstack/react-query 4.14.3 → 4.14.6

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.
@@ -826,14 +826,16 @@
826
826
  this.queryHash = config.queryHash;
827
827
  this.initialState = config.state || getDefaultState$1(this.options);
828
828
  this.state = this.initialState;
829
- this.meta = config.meta;
829
+ }
830
+
831
+ get meta() {
832
+ return this.options.meta;
830
833
  }
831
834
 
832
835
  setOptions(options) {
833
836
  this.options = { ...this.defaultOptions,
834
837
  ...options
835
838
  };
836
- this.meta = options == null ? void 0 : options.meta;
837
839
  this.updateCacheTime(this.options.cacheTime);
838
840
  }
839
841
 
@@ -1063,8 +1065,7 @@
1063
1065
  options: this.options,
1064
1066
  queryKey: this.queryKey,
1065
1067
  state: this.state,
1066
- fetchFn,
1067
- meta: this.meta
1068
+ fetchFn
1068
1069
  };
1069
1070
  addSignalProperty(context);
1070
1071
  (_this$options$behavio = this.options.behavior) == null ? void 0 : _this$options$behavio.onFetch(context); // Store state in case the current fetch needs to be reverted
@@ -1298,8 +1299,7 @@
1298
1299
  queryHash,
1299
1300
  options: client.defaultQueryOptions(options),
1300
1301
  state,
1301
- defaultOptions: client.getQueryDefaults(queryKey),
1302
- meta: options.meta
1302
+ defaultOptions: client.getQueryDefaults(queryKey)
1303
1303
  });
1304
1304
  this.add(query);
1305
1305
  }
@@ -1405,11 +1405,14 @@
1405
1405
  this.logger = config.logger || defaultLogger;
1406
1406
  this.observers = [];
1407
1407
  this.state = config.state || getDefaultState();
1408
- this.meta = config.meta;
1409
1408
  this.updateCacheTime(this.options.cacheTime);
1410
1409
  this.scheduleGc();
1411
1410
  }
1412
1411
 
1412
+ get meta() {
1413
+ return this.options.meta;
1414
+ }
1415
+
1413
1416
  setState(state) {
1414
1417
  this.dispatch({
1415
1418
  type: 'setState',
@@ -1654,8 +1657,7 @@
1654
1657
  mutationId: ++this.mutationId,
1655
1658
  options: client.defaultMutationOptions(options),
1656
1659
  state,
1657
- defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined,
1658
- meta: options.meta
1660
+ defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined
1659
1661
  });
1660
1662
  this.add(mutation);
1661
1663
  return mutation;
@@ -1774,7 +1776,7 @@
1774
1776
  const queryFnContext = {
1775
1777
  queryKey: context.queryKey,
1776
1778
  pageParam: param,
1777
- meta: context.meta
1779
+ meta: context.options.meta
1778
1780
  };
1779
1781
  addSignalProperty(queryFnContext);
1780
1782
  const queryFnResult = queryFn(queryFnContext);
@@ -2910,19 +2912,26 @@
2910
2912
  }
2911
2913
 
2912
2914
  createResult(query, options) {
2913
- var _state$data, _state$data2, _state$fetchMeta, _state$fetchMeta$fetc, _state$fetchMeta2, _state$fetchMeta2$fet;
2915
+ var _state$fetchMeta, _state$fetchMeta$fetc, _state$fetchMeta2, _state$fetchMeta2$fet, _state$data, _state$data2;
2914
2916
 
2915
2917
  const {
2916
2918
  state
2917
2919
  } = query;
2918
2920
  const result = super.createResult(query, options);
2921
+ const {
2922
+ isFetching,
2923
+ isRefetching
2924
+ } = result;
2925
+ const isFetchingNextPage = isFetching && ((_state$fetchMeta = state.fetchMeta) == null ? void 0 : (_state$fetchMeta$fetc = _state$fetchMeta.fetchMore) == null ? void 0 : _state$fetchMeta$fetc.direction) === 'forward';
2926
+ const isFetchingPreviousPage = isFetching && ((_state$fetchMeta2 = state.fetchMeta) == null ? void 0 : (_state$fetchMeta2$fet = _state$fetchMeta2.fetchMore) == null ? void 0 : _state$fetchMeta2$fet.direction) === 'backward';
2919
2927
  return { ...result,
2920
2928
  fetchNextPage: this.fetchNextPage,
2921
2929
  fetchPreviousPage: this.fetchPreviousPage,
2922
2930
  hasNextPage: hasNextPage(options, (_state$data = state.data) == null ? void 0 : _state$data.pages),
2923
2931
  hasPreviousPage: hasPreviousPage(options, (_state$data2 = state.data) == null ? void 0 : _state$data2.pages),
2924
- isFetchingNextPage: state.fetchStatus === 'fetching' && ((_state$fetchMeta = state.fetchMeta) == null ? void 0 : (_state$fetchMeta$fetc = _state$fetchMeta.fetchMore) == null ? void 0 : _state$fetchMeta$fetc.direction) === 'forward',
2925
- isFetchingPreviousPage: state.fetchStatus === 'fetching' && ((_state$fetchMeta2 = state.fetchMeta) == null ? void 0 : (_state$fetchMeta2$fet = _state$fetchMeta2.fetchMore) == null ? void 0 : _state$fetchMeta2$fet.direction) === 'backward'
2932
+ isFetchingNextPage,
2933
+ isFetchingPreviousPage,
2934
+ isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
2926
2935
  };
2927
2936
  }
2928
2937