@tanstack/router-core 1.130.2 → 1.130.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.
@@ -691,30 +691,21 @@ class RouterCore {
691
691
  };
692
692
  this.updateMatch = (id, updater) => {
693
693
  var _a;
694
- let updated;
695
- const isPending = (_a = this.state.pendingMatches) == null ? void 0 : _a.find((d) => d.id === id);
696
- const isMatched = this.state.matches.find((d) => d.id === id);
697
- const isCached = this.state.cachedMatches.find((d) => d.id === id);
698
- const matchesKey = isPending ? "pendingMatches" : isMatched ? "matches" : isCached ? "cachedMatches" : "";
694
+ const matchesKey = ((_a = this.state.pendingMatches) == null ? void 0 : _a.some((d) => d.id === id)) ? "pendingMatches" : this.state.matches.some((d) => d.id === id) ? "matches" : this.state.cachedMatches.some((d) => d.id === id) ? "cachedMatches" : "";
699
695
  if (matchesKey) {
700
696
  this.__store.setState((s) => {
701
697
  var _a2;
702
698
  return {
703
699
  ...s,
704
- [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map(
705
- (d) => d.id === id ? updated = updater(d) : d
706
- )
700
+ [matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map((d) => d.id === id ? updater(d) : d)
707
701
  };
708
702
  });
709
703
  }
710
- return updated;
711
704
  };
712
705
  this.getMatch = (matchId) => {
713
- return [
714
- ...this.state.cachedMatches,
715
- ...this.state.pendingMatches ?? [],
716
- ...this.state.matches
717
- ].find((d) => d.id === matchId);
706
+ var _a;
707
+ const findFn = (d) => d.id === matchId;
708
+ return this.state.cachedMatches.find(findFn) ?? ((_a = this.state.pendingMatches) == null ? void 0 : _a.find(findFn)) ?? this.state.matches.find(findFn);
718
709
  };
719
710
  this.loadMatches = async ({
720
711
  location,
@@ -1281,7 +1272,10 @@ class RouterCore {
1281
1272
  return true;
1282
1273
  }
1283
1274
  const gcTime = (d.preload ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime : route.options.gcTime ?? this.options.defaultGcTime) ?? 5 * 60 * 1e3;
1284
- return !(d.status !== "error" && Date.now() - d.updatedAt < gcTime);
1275
+ const isError = d.status === "error";
1276
+ if (isError) return true;
1277
+ const isStale = Date.now() - d.updatedAt >= gcTime;
1278
+ return isStale;
1285
1279
  };
1286
1280
  this.clearCache({ filter });
1287
1281
  };