@@ -38,6 +38,7 @@ export default function ACARS() {
3838 const [ activeSessions , setActiveSessions ] = useState < OverviewSession [ ] > ( [ ] ) ;
3939 const [ error , setError ] = useState < string | null > ( null ) ;
4040 const [ pdcRequested , setPdcRequested ] = useState ( false ) ;
41+ const [ sessionAccessId , setSessionAccessId ] = useState < string | null > ( null ) ;
4142
4243 const audioRef = useRef < HTMLAudioElement | null > ( null ) ;
4344 const chatPopRef = useRef < HTMLAudioElement | null > ( null ) ;
@@ -88,11 +89,13 @@ export default function ACARS() {
8889 throw new Error ( 'Failed to validate access' ) ;
8990 }
9091
91- const { valid } = await validateResponse . json ( ) ;
92+ const { valid, accessId : sessionAccess } = await validateResponse . json ( ) ;
9293 if ( ! valid ) {
9394 throw new Error ( 'Invalid access token' ) ;
9495 }
9596
97+ setSessionAccessId ( sessionAccess ) ;
98+
9699 const flightResponse = await fetch (
97100 `${ import . meta. env . VITE_SERVER_URL } /api/flights/${ sessionId } ` ,
98101 { credentials : 'include' }
@@ -251,13 +254,13 @@ export default function ACARS() {
251254 } , [ ] ) ;
252255
253256 useEffect ( ( ) => {
254- if ( ! sessionId || loading ) {
257+ if ( ! sessionId || loading || ! sessionAccessId ) {
255258 return ;
256259 }
257260
258261 const socket = createFlightsSocket (
259262 sessionId ,
260- accessId || '' ,
263+ sessionAccessId ,
261264 ( ) => { } ,
262265 ( ) => { } ,
263266 ( ) => { } ,
@@ -305,7 +308,7 @@ export default function ACARS() {
305308 socket . socket . disconnect ( ) ;
306309 socketRef . current = null ;
307310 } ;
308- } , [ sessionId , flightId , loading , accessId ] ) ;
311+ } , [ sessionId , flightId , loading , sessionAccessId ] ) ;
309312
310313 useEffect ( ( ) => {
311314 const overviewSocket = createOverviewSocket ( ( data ) => {
0 commit comments