Fix jwt-token
This commit is contained in:
@@ -109,6 +109,7 @@ const MapView = () => {
|
||||
const [mapCenter, setMapCenter] = useState([59.3293, 18.0686]); // Default to Stockholm center
|
||||
const [mapZoom, setMapZoom] = useState(10); // Default zoom level
|
||||
const [mapBounds, setMapBounds] = useState(null);
|
||||
const [isInitialLoad, setIsInitialLoad] = useState(true); // Track if this is the first load
|
||||
const [showDroneDetections, setShowDroneDetections] = useState(true);
|
||||
const [droneDetectionHistory, setDroneDetectionHistory] = useState([]);
|
||||
const { recentDetections, deviceStatus } = useSocket();
|
||||
@@ -166,6 +167,10 @@ const MapView = () => {
|
||||
|
||||
const fetchDevices = async () => {
|
||||
try {
|
||||
// Debug: Check if token exists before making request
|
||||
const token = localStorage.getItem('token');
|
||||
console.log('MapView: fetchDevices - Token exists:', !!token, 'Token length:', token?.length);
|
||||
|
||||
const response = await api.get('/devices/map');
|
||||
const deviceData = response.data.data;
|
||||
|
||||
@@ -192,10 +197,13 @@ const MapView = () => {
|
||||
|
||||
setMapBounds(bounds);
|
||||
|
||||
// Set center to the middle of all devices
|
||||
const centerLat = (minLat + maxLat) / 2;
|
||||
const centerLon = (minLon + maxLon) / 2;
|
||||
setMapCenter([centerLat, centerLon]);
|
||||
// Only set center on initial load, not on periodic refreshes
|
||||
if (isInitialLoad) {
|
||||
const centerLat = (minLat + maxLat) / 2;
|
||||
const centerLon = (minLon + maxLon) / 2;
|
||||
setMapCenter([centerLat, centerLon]);
|
||||
setIsInitialLoad(false); // Mark that initial load is complete
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching devices:', error);
|
||||
|
||||
Reference in New Issue
Block a user