@tanstack/vue-query 4.14.1 → 4.14.5

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.
@@ -802,14 +802,16 @@
802
802
  this.queryHash = config.queryHash;
803
803
  this.initialState = config.state || getDefaultState$1(this.options);
804
804
  this.state = this.initialState;
805
- this.meta = config.meta;
805
+ }
806
+
807
+ get meta() {
808
+ return this.options.meta;
806
809
  }
807
810
 
808
811
  setOptions(options) {
809
812
  this.options = { ...this.defaultOptions,
810
813
  ...options
811
814
  };
812
- this.meta = options == null ? void 0 : options.meta;
813
815
  this.updateCacheTime(this.options.cacheTime);
814
816
  }
815
817
 
@@ -1039,8 +1041,7 @@
1039
1041
  options: this.options,
1040
1042
  queryKey: this.queryKey,
1041
1043
  state: this.state,
1042
- fetchFn,
1043
- meta: this.meta
1044
+ fetchFn
1044
1045
  };
1045
1046
  addSignalProperty(context);
1046
1047
  (_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
@@ -1274,8 +1275,7 @@
1274
1275
  queryHash,
1275
1276
  options: client.defaultQueryOptions(options),
1276
1277
  state,
1277
- defaultOptions: client.getQueryDefaults(queryKey),
1278
- meta: options.meta
1278
+ defaultOptions: client.getQueryDefaults(queryKey)
1279
1279
  });
1280
1280
  this.add(query);
1281
1281
  }
@@ -1381,11 +1381,14 @@
1381
1381
  this.logger = config.logger || defaultLogger;
1382
1382
  this.observers = [];
1383
1383
  this.state = config.state || getDefaultState();
1384
- this.meta = config.meta;
1385
1384
  this.updateCacheTime(this.options.cacheTime);
1386
1385
  this.scheduleGc();
1387
1386
  }
1388
1387
 
1388
+ get meta() {
1389
+ return this.options.meta;
1390
+ }
1391
+
1389
1392
  setState(state) {
1390
1393
  this.dispatch({
1391
1394
  type: 'setState',
@@ -1630,8 +1633,7 @@
1630
1633
  mutationId: ++this.mutationId,
1631
1634
  options: client.defaultMutationOptions(options),
1632
1635
  state,
1633
- defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined,
1634
- meta: options.meta
1636
+ defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined
1635
1637
  });
1636
1638
  this.add(mutation);
1637
1639
  return mutation;
@@ -1750,7 +1752,7 @@
1750
1752
  const queryFnContext = {
1751
1753
  queryKey: context.queryKey,
1752
1754
  pageParam: param,
1753
- meta: context.meta
1755
+ meta: context.options.meta
1754
1756
  };
1755
1757
  addSignalProperty(queryFnContext);
1756
1758
  const queryFnResult = queryFn(queryFnContext);
@@ -2886,19 +2888,26 @@
2886
2888
  }
2887
2889
 
2888
2890
  createResult(query, options) {
2889
- var _state$data, _state$data2, _state$fetchMeta, _state$fetchMeta$fetc, _state$fetchMeta2, _state$fetchMeta2$fet;
2891
+ var _state$fetchMeta, _state$fetchMeta$fetc, _state$fetchMeta2, _state$fetchMeta2$fet, _state$data, _state$data2;
2890
2892
 
2891
2893
  const {
2892
2894
  state
2893
2895
  } = query;
2894
2896
  const result = super.createResult(query, options);
2897
+ const {
2898
+ isFetching,
2899
+ isRefetching
2900
+ } = result;
2901
+ const isFetchingNextPage = isFetching && ((_state$fetchMeta = state.fetchMeta) == null ? void 0 : (_state$fetchMeta$fetc = _state$fetchMeta.fetchMore) == null ? void 0 : _state$fetchMeta$fetc.direction) === 'forward';
2902
+ const isFetchingPreviousPage = isFetching && ((_state$fetchMeta2 = state.fetchMeta) == null ? void 0 : (_state$fetchMeta2$fet = _state$fetchMeta2.fetchMore) == null ? void 0 : _state$fetchMeta2$fet.direction) === 'backward';
2895
2903
  return { ...result,
2896
2904
  fetchNextPage: this.fetchNextPage,
2897
2905
  fetchPreviousPage: this.fetchPreviousPage,
2898
2906
  hasNextPage: hasNextPage(options, (_state$data = state.data) == null ? void 0 : _state$data.pages),
2899
2907
  hasPreviousPage: hasPreviousPage(options, (_state$data2 = state.data) == null ? void 0 : _state$data2.pages),
2900
- 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',
2901
- 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'
2908
+ isFetchingNextPage,
2909
+ isFetchingPreviousPage,
2910
+ isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
2902
2911
  };
2903
2912
  }
2904
2913