@@ -17,23 +17,20 @@ export const ClientConditionalRenderer = ({
17
17
revalidateTags,
18
18
resolvedRef,
19
19
getLatestBranches,
20
- humanRevalidatePendingTags,
21
20
} : {
22
21
draft : boolean ;
23
22
isForcedDraft : boolean ;
24
23
enableDraftMode : ( o : {
25
24
bshbPreviewToken : string ;
26
25
} ) => Promise < { status : number ; response : object } > ;
27
26
disableDraftMode : ( ) => Promise < void > ;
28
- revalidateTags : ( o : { tags : string [ ] } ) => Promise < { success : boolean } > ;
27
+ revalidateTags : ( o : {
28
+ bshbPreviewToken : string ;
29
+ } ) => Promise < { success : boolean } > ;
29
30
getLatestBranches : ( o : { bshbPreviewToken : string | undefined } ) => Promise < {
30
31
status : number ;
31
32
response : LatestBranch [ ] | { error : string } ;
32
33
} > ;
33
- humanRevalidatePendingTags : ( o : {
34
- bshbPreviewToken : string ;
35
- ref : string ;
36
- } ) => Promise < { success : boolean } > ;
37
34
resolvedRef : ResolvedRef ;
38
35
} ) => {
39
36
const [ hasRendered , setHasRendered ] = React . useState ( false ) ;
@@ -87,17 +84,19 @@ export const ClientConditionalRenderer = ({
87
84
88
85
React . useEffect ( ( ) => {
89
86
const url = new URL ( window . location . href ) ;
90
- const tags = url . searchParams . get ( "bshb -odr-tags" ) ;
91
- if ( tags ) {
92
- url . searchParams . delete ( "bshb-odr-tags" ) ;
93
- window . history . replaceState ( null , "" , url ) ;
94
- revalidateTags ( { tags : tags . split ( "," ) } )
87
+ const shouldRevalidate = url . searchParams . get ( "__bshb -odr" ) === "true" ;
88
+ const odrToken = url . searchParams . get ( "__bshb-odr-token" ) ;
89
+
90
+ if ( shouldRevalidate && odrToken ) {
91
+ revalidateTags ( { bshbPreviewToken : odrToken } )
95
92
. then ( ( { success } ) => {
96
93
document . documentElement . dataset . basehubOdrStatus = success
97
94
? "success"
98
95
: "error" ;
99
- document . documentElement . dataset . basehubOdrErrorMessage =
100
- "Response failed" ;
96
+ if ( ! success ) {
97
+ document . documentElement . dataset . basehubOdrErrorMessage =
98
+ "Response failed" ;
99
+ }
101
100
} )
102
101
. catch ( ( e ) => {
103
102
document . documentElement . dataset . basehubOdrStatus = "error" ;
@@ -132,7 +131,6 @@ export const ClientConditionalRenderer = ({
132
131
seekAndStoreBshbPreviewToken = { seekAndStoreBshbPreviewToken }
133
132
resolvedRef = { resolvedRef }
134
133
getLatestBranches = { getLatestBranches }
135
- humanRevalidatePendingTags = { humanRevalidatePendingTags }
136
134
bshbPreviewLSName = { bshbPreviewLSName }
137
135
/> ,
138
136
document . body
0 commit comments