Unverified Commit e7b58935 authored by Andrew Clark's avatar Andrew Clark Committed by GitHub

Remove PPR feature check from Segment Cache client (#74669)

Follow-up to #73960. We should no longer check if PPR is enabled when
determining whether to use the Segment Cache or the old client cache.
parent 1f4fa25f
...@@ -275,30 +275,29 @@ function Router({ ...@@ -275,30 +275,29 @@ function Router({
const routerInstance: AppRouterInstance = { const routerInstance: AppRouterInstance = {
back: () => window.history.back(), back: () => window.history.back(),
forward: () => window.history.forward(), forward: () => window.history.forward(),
prefetch: prefetch: process.env.__NEXT_CLIENT_SEGMENT_CACHE
process.env.__NEXT_PPR && process.env.__NEXT_CLIENT_SEGMENT_CACHE ? // Unlike the old implementation, the Segment Cache doesn't store its
? // Unlike the old implementation, the Segment Cache doesn't store its // data in the router reducer state; it writes into a global mutable
// data in the router reducer state; it writes into a global mutable // cache. So we don't need to dispatch an action.
// cache. So we don't need to dispatch an action. (href) =>
(href) => prefetchWithSegmentCache(
prefetchWithSegmentCache( href,
href, actionQueue.state.nextUrl,
actionQueue.state.nextUrl, actionQueue.state.tree
actionQueue.state.tree )
) : (href, options) => {
: (href, options) => { // Use the old prefetch implementation.
// Use the old prefetch implementation. const url = createPrefetchURL(href)
const url = createPrefetchURL(href) if (url !== null) {
if (url !== null) { startTransition(() => {
startTransition(() => { dispatch({
dispatch({ type: ACTION_PREFETCH,
type: ACTION_PREFETCH, url,
url, kind: options?.kind ?? PrefetchKind.FULL,
kind: options?.kind ?? PrefetchKind.FULL,
})
}) })
} })
}, }
},
replace: (href, options = {}) => { replace: (href, options = {}) => {
startTransition(() => { startTransition(() => {
navigate(href, 'replace', options.scroll ?? true) navigate(href, 'replace', options.scroll ?? true)
......
...@@ -173,7 +173,7 @@ export function navigateReducer( ...@@ -173,7 +173,7 @@ export function navigateReducer(
return handleExternalUrl(state, mutable, href, pendingPush) return handleExternalUrl(state, mutable, href, pendingPush)
} }
if (process.env.__NEXT_PPR && process.env.__NEXT_CLIENT_SEGMENT_CACHE) { if (process.env.__NEXT_CLIENT_SEGMENT_CACHE) {
// (Very Early Experimental Feature) Segment Cache // (Very Early Experimental Feature) Segment Cache
// //
// Bypass the normal prefetch cache and use the new per-segment cache // Bypass the normal prefetch cache and use the new per-segment cache
......
...@@ -11,10 +11,9 @@ import { ...@@ -11,10 +11,9 @@ import {
export const prefetchQueue = new PromiseQueue(5) export const prefetchQueue = new PromiseQueue(5)
export const prefetchReducer = export const prefetchReducer = process.env.__NEXT_CLIENT_SEGMENT_CACHE
process.env.__NEXT_PPR && process.env.__NEXT_CLIENT_SEGMENT_CACHE ? identityReducerWhenSegmentCacheIsEnabled
? identityReducerWhenSegmentCacheIsEnabled : prefetchReducerImpl
: prefetchReducerImpl
function identityReducerWhenSegmentCacheIsEnabled<T>(state: T): T { function identityReducerWhenSegmentCacheIsEnabled<T>(state: T): T {
// Unlike the old implementation, the Segment Cache doesn't store its data in // Unlike the old implementation, the Segment Cache doesn't store its data in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment