Skip to content

Commit

Permalink
re-arrange some things
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Feb 9, 2024
1 parent 58ab5c3 commit 1f62f69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export function getOrCreatePrefetchCacheEntry({
})
}

/*
* Used to take an existing cache entry and prefix it with the nextUrl, if it exists.
* This ensures that we don't have conflicting cache entries for the same URL (as is the case with route interception).
*/
function prefixExistingPrefetchCacheEntry({
url,
nextUrl,
Expand All @@ -136,7 +140,7 @@ function prefixExistingPrefetchCacheEntry({
}

/**
* Use to seed the prefetch cache with an entry for already-resolved data
* Use to seed the prefetch cache with data that has already been fetched.
*/
export function createPrefetchEntry({
nextUrl,
Expand Down Expand Up @@ -172,7 +176,7 @@ export function createPrefetchEntry({
}

/**
* Creates a prefetch entry for data that has not been resolved. This will add the prefetch request to a promise queue.
* Creates a prefetch entry entry and enqueues a fetch request to retrieve the data.
*/
function createLazyPrefetchEntry({
url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function navigateReducer_noPPR(
return data.then(
([flightData, canonicalUrlOverride]) => {
// we only want to mark this once
if (prefetchValues && !prefetchValues.lastUsedTime) {
if (!prefetchValues.lastUsedTime) {
// important: we should only mark the cache node as dirty after we unsuspend from the call above
prefetchValues.lastUsedTime = Date.now()
}
Expand Down Expand Up @@ -196,7 +196,7 @@ function navigateReducer_noPPR(
currentCache,
cache,
flightDataPath,
prefetchValues?.kind === 'auto' &&
prefetchValues.kind === 'auto' &&
prefetchEntryCacheStatus === PrefetchCacheEntryStatus.reusable
)

Expand Down Expand Up @@ -312,7 +312,7 @@ function navigateReducer_PPR(
return data.then(
([flightData, canonicalUrlOverride, _postponed]) => {
// we only want to mark this once
if (prefetchValues && !prefetchValues.lastUsedTime) {
if (!prefetchValues.lastUsedTime) {
// important: we should only mark the cache node as dirty after we unsuspend from the call above
prefetchValues.lastUsedTime = Date.now()
}
Expand Down Expand Up @@ -449,7 +449,7 @@ function navigateReducer_PPR(
currentCache,
cache,
flightDataPath,
prefetchValues?.kind === 'auto' &&
prefetchValues.kind === 'auto' &&
prefetchEntryCacheStatus === PrefetchCacheEntryStatus.reusable
)

Expand Down

0 comments on commit 1f62f69

Please sign in to comment.