@@ -11,9 +11,8 @@ import { Scope } from "@navigraph/app";
11
11
import "leaflet/dist/leaflet.css"
12
12
import { mapFaaState , mapSourceState , mapTacState , mapThemeState } from "../../state/mapStyle" ;
13
13
import { chartOverlayOpacityState , chartOverlayState } from "../../state/chartOverlay" ;
14
- import { calculateChartBounds } from "@navigraph/charts" ;
14
+ import { calculateChartBounds , getChartsAPI } from "@navigraph/charts" ;
15
15
import { useQuery } from "@tanstack/react-query" ;
16
- import { protectedPage } from "../protectedPage" ;
17
16
import { TbCircleX } from "react-icons/tb" ;
18
17
import Button from "../Button" ;
19
18
import AmdbManager from "./amdb" ;
@@ -29,7 +28,7 @@ export function createPreset(source: NavigraphRasterSource, theme: NavigraphThem
29
28
return { source, theme, type : faa ? 'FAA' : 'Navigraph' }
30
29
}
31
30
32
- const ChartOverlay = protectedPage ( ( { charts } ) => {
31
+ const ChartOverlay = ( { charts } : { charts : ReturnType < typeof getChartsAPI > } ) => {
33
32
const theme = useRecoilValue ( mapThemeState ) ;
34
33
35
34
const opacity = useRecoilValue ( chartOverlayOpacityState ) ;
@@ -72,7 +71,7 @@ const ChartOverlay = protectedPage(({ charts }) => {
72
71
opacity = { opacity }
73
72
/>
74
73
)
75
- } , [ Scope . CHARTS ] ) ;
74
+ } ;
76
75
77
76
function NavigraphTiles ( { auth } : { auth : NavigraphAuth } ) {
78
77
const map = useMap ( ) ;
@@ -131,6 +130,8 @@ export default function MapPane() {
131
130
const app = useRecoilValue ( appState ) ;
132
131
const user = useRecoilValue ( userState ) ;
133
132
133
+ const charts = user ?. scope . includes ( Scope . CHARTS ) ? getChartsAPI ( ) : undefined ;
134
+
134
135
return (
135
136
< div className = 'w-full' >
136
137
< MapContainer center = { [ 51.505 , - 0.09 ] } zoom = { 13 } className = 'h-screen' zoomControl = { false } ref = { mapRef } whenReady = { ( ) => {
@@ -145,7 +146,7 @@ export default function MapPane() {
145
146
url = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
146
147
/>
147
148
) }
148
- < ChartOverlay />
149
+ { charts && < ChartOverlay charts = { charts } /> }
149
150
< AmdbManager />
150
151
</ MapContainer >
151
152
</ div >
0 commit comments