@@ -38,6 +38,23 @@ const Link = ({ children, href }: { children: ReactNode; href: string }) => (
38
38
</ a >
39
39
) ;
40
40
41
+ const tryHandlePageTitle = ( {
42
+ title,
43
+ version,
44
+ } : {
45
+ title : string ;
46
+ version : string ;
47
+ } ) => {
48
+ try {
49
+ const pageTitle = `${ title } ${ version } | Speakeasy OpenAPI Overlay Playground` ;
50
+ if ( document . title !== pageTitle ) {
51
+ document . title = pageTitle ;
52
+ }
53
+ } catch ( e : unknown ) {
54
+ console . error ( e ) ;
55
+ }
56
+ } ;
57
+
41
58
function Playground ( ) {
42
59
const [ ready , setReady ] = useState ( false ) ;
43
60
@@ -136,8 +153,10 @@ function Playground() {
136
153
) ;
137
154
if ( changedNew . type == "success" ) {
138
155
const info = await GetInfo ( original . current , false ) ;
156
+ const parsedInfo = JSON . parse ( info ) ;
157
+ tryHandlePageTitle ( parsedInfo ) ;
139
158
posthog . capture ( "overlay.speakeasy.com:load-shared" , {
140
- openapi : JSON . parse ( info ) ,
159
+ openapi : parsedInfo ,
141
160
} ) ;
142
161
changed . current = changedNew . result ;
143
162
}
@@ -179,6 +198,8 @@ function Playground() {
179
198
true ,
180
199
) ;
181
200
result . current = res ;
201
+ const info = await GetInfo ( original . current , false ) ;
202
+ tryHandlePageTitle ( JSON . parse ( info ) ) ;
182
203
setError ( "" ) ;
183
204
} catch ( e : unknown ) {
184
205
if ( e instanceof Error ) {
@@ -204,6 +225,8 @@ function Playground() {
204
225
result . current ,
205
226
true ,
206
227
) ;
228
+ const info = await GetInfo ( changed . current , false ) ;
229
+ tryHandlePageTitle ( JSON . parse ( info ) ) ;
207
230
setError ( "" ) ;
208
231
} catch ( e : unknown ) {
209
232
if ( e instanceof Error ) {
@@ -233,6 +256,8 @@ function Playground() {
233
256
changed . current = response . result || "" ;
234
257
setError ( "" ) ;
235
258
setOverlayMarkers ( [ ] ) ;
259
+ const info = await GetInfo ( changed . current , false ) ;
260
+ tryHandlePageTitle ( JSON . parse ( info ) ) ;
236
261
} else if ( response . type == "incomplete" ) {
237
262
setApplyOverlayMode ( "jsonpathexplorer" ) ;
238
263
changed . current = response . result || "" ;
@@ -264,22 +289,6 @@ function Playground() {
264
289
265
290
const onChangeCDebounced = useDebounceCallback ( onChangeC , 500 ) ;
266
291
267
- useEffect ( ( ) => {
268
- const tryHandlePageTitle = async ( ) => {
269
- try {
270
- const info = await GetInfo ( original . current ) ;
271
- const { title, version } = JSON . parse ( info ) ;
272
- const pageTitle = `${ title } ${ version } | Speakeasy OpenAPI Overlay Playground` ;
273
- if ( document . title !== pageTitle ) {
274
- document . title = pageTitle ;
275
- }
276
- } catch ( e : unknown ) {
277
- console . error ( e ) ;
278
- }
279
- } ;
280
- tryHandlePageTitle ( ) ;
281
- } , [ original ] ) ;
282
-
283
292
const ref = useRef < ImperativePanelGroupHandle > ( null ) ;
284
293
285
294
const maxLayout = useCallback ( ( index : number ) => {
0 commit comments