@@ -68,7 +68,7 @@ class PrefetchedRequests {
6868 } ) . then ( ( response ) => {
6969 this . remove ( params )
7070
71- this . preserveOncePropsInResponse ( response )
71+ currentPage . passOncePropsTo ( response . getPageResponse ( ) )
7272
7373 this . cached . push ( {
7474 params : { ...params } ,
@@ -264,27 +264,14 @@ class PrefetchedRequests {
264264 )
265265 }
266266
267- public updateCachedResponsesWithOnceProps ( ) : void {
268- const current = currentPage . get ( )
269-
270- if ( Object . keys ( current . onceProps ?? { } ) . length === 0 ) {
267+ public syncCachedOnceProps ( ) : void {
268+ if ( Object . keys ( currentPage . get ( ) . onceProps ?? { } ) . length === 0 ) {
271269 return
272270 }
273271
274272 this . cached . forEach ( ( prefetched ) => {
275273 prefetched . response . then ( ( response ) => {
276- const page = response . getPageResponse ( )
277-
278- Object . entries ( page . onceProps ?? { } ) . forEach ( ( [ key , onceProp ] ) => {
279- const existingOnceProp = current . onceProps ?. [ key ]
280-
281- if ( existingOnceProp === undefined ) {
282- return
283- }
284-
285- page . props [ onceProp . prop ] = current . props [ existingOnceProp . prop ]
286- page . onceProps ! [ key ] . expiresAt = existingOnceProp . expiresAt
287- } )
274+ currentPage . passOncePropsTo ( response . getPageResponse ( ) , { overwrite : true } )
288275
289276 const oncePropsExpiresIn = this . getOncePropsExpiresIn ( response )
290277
@@ -302,24 +289,6 @@ class PrefetchedRequests {
302289 } )
303290 }
304291
305- protected preserveOncePropsInResponse ( response : Response ) : void {
306- const current = currentPage . get ( )
307- const page = response . getPageResponse ( )
308-
309- Object . entries ( page . onceProps ?? { } ) . forEach ( ( [ key , onceProp ] ) => {
310- const existingOnceProp = current . onceProps ?. [ key ]
311-
312- if ( existingOnceProp === undefined ) {
313- return
314- }
315-
316- if ( page . props [ onceProp . prop ] === undefined ) {
317- page . props [ onceProp . prop ] = current . props [ existingOnceProp . prop ]
318- page . onceProps ! [ key ] . expiresAt = existingOnceProp . expiresAt
319- }
320- } )
321- }
322-
323292 protected getOncePropsExpiresIn ( response : Response ) : number | null {
324293 const page = response . getPageResponse ( )
325294 const expiryTimes = Object . values ( page . onceProps ?? { } )
0 commit comments