@@ -7,6 +7,7 @@ import { updateOverlays } from "@/components/Map/utils/events";
77import { getMapView } from "@/components/Map/utils/init" ;
88import { initPilotFeatures , updatePilotFeatures } from "@/components/Map/utils/pilotFeatures" ;
99import { updateTrackFeatures } from "@/components/Map/utils/trackFeatures" ;
10+ import type { StatusMap } from "@/types/data" ;
1011import { wsClient } from "@/utils/ws" ;
1112import { dxGetAirline , dxGetAirport , dxGetFirs , dxGetTracons , dxInitDatabases } from "./dexie" ;
1213
@@ -19,9 +20,15 @@ const cachedAirlines: Map<string, StaticAirline> = new Map();
1920const cachedTracons : Map < string , SimAwareTraconFeature > = new Map ( ) ;
2021const cachedFirs : Map < string , FIRFeature > = new Map ( ) ;
2122
22- export async function initData ( ) : Promise < void > {
23+ type StatusSetter = ( status : Partial < StatusMap > | ( ( prev : Partial < StatusMap > ) => Partial < StatusMap > ) ) => void ;
24+
25+ export async function initData ( setStatus ?: StatusSetter ) : Promise < void > {
2326 await dxInitDatabases ( ) ;
27+ setStatus ?.( ( prev ) => ( { ...prev , indexedDB : true } ) ) ;
28+
2429 const data = ( await fetch ( `${ BASE_URL } /api/data/init` ) . then ( ( res ) => res . json ( ) ) ) as WsAll ;
30+ setStatus ?.( ( prev ) => ( { ...prev , initData : true } ) ) ;
31+
2532 await initAirportFeatures ( ) ;
2633 initPilotFeatures ( data . pilots ) ;
2734 initControllerFeatures ( data . controllers ) ;
@@ -33,6 +40,7 @@ export async function initData(): Promise<void> {
3340 if ( view ) {
3441 setFeatures ( view . calculateExtent ( ) , view . getZoom ( ) || 5 ) ;
3542 }
43+ setStatus ?.( ( prev ) => ( { ...prev , initMap : true } ) ) ;
3644
3745 wsClient . addListener ( ( msg ) => {
3846 updateCache ( msg ) ;
0 commit comments