navgo 6.0.0 → 6.0.2
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/index.js +22 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -511,9 +511,28 @@ export default class Navgo {
|
|
|
511
511
|
res = entry
|
|
512
512
|
source = 'cache'
|
|
513
513
|
} else if (strategy === 'swr' && entry) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
514
|
+
if (fresh) {
|
|
515
|
+
res = entry
|
|
516
|
+
source = 'cache'
|
|
517
|
+
} else if (nav_id === 0) {
|
|
518
|
+
// Preload should not freeze a stale snapshot into #preloads.
|
|
519
|
+
// Fetch now so goto() reuses fresh data.
|
|
520
|
+
try {
|
|
521
|
+
res = await this.#fetch_and_cache(
|
|
522
|
+
req,
|
|
523
|
+
cache,
|
|
524
|
+
side,
|
|
525
|
+
tags,
|
|
526
|
+
controller.signal,
|
|
527
|
+
)
|
|
528
|
+
source = 'network'
|
|
529
|
+
} catch {
|
|
530
|
+
res = entry
|
|
531
|
+
source = 'stale'
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
534
|
+
res = entry
|
|
535
|
+
source = 'stale'
|
|
517
536
|
this.#fetch_and_cache(req, cache, side, tags, controller.signal)
|
|
518
537
|
.then(r => this.#parse_response(r.clone ? r.clone() : r, parse))
|
|
519
538
|
.then(v => this.#emit_revalidate(nav_id, as, v))
|