|
@@ -4,7 +4,7 @@ import MapView, { Geojson, Marker, UrlTile } from 'react-native-maps';
|
|
import * as turf from '@turf/turf';
|
|
import * as turf from '@turf/turf';
|
|
import * as FileSystem from 'expo-file-system';
|
|
import * as FileSystem from 'expo-file-system';
|
|
import * as Location from 'expo-location';
|
|
import * as Location from 'expo-location';
|
|
-import { storage, StoreType } from '../../../storage';
|
|
|
|
|
|
+import { getOnlineStatus, storage, StoreType } from '../../../storage';
|
|
|
|
|
|
import MenuIcon from '../../../../assets/icons/menu.svg';
|
|
import MenuIcon from '../../../../assets/icons/menu.svg';
|
|
import SearchIcon from '../../../../assets/icons/search.svg';
|
|
import SearchIcon from '../../../../assets/icons/search.svg';
|
|
@@ -46,7 +46,7 @@ import {
|
|
const MAP_HOST = 'https://maps.nomadmania.eu';
|
|
const MAP_HOST = 'https://maps.nomadmania.eu';
|
|
|
|
|
|
const tilesBaseURL = `${MAP_HOST}/tiles_osm`;
|
|
const tilesBaseURL = `${MAP_HOST}/tiles_osm`;
|
|
-const localTileDir = `${FileSystem.cacheDirectory}tiles`;
|
|
|
|
|
|
+const localTileDir = `${FileSystem.cacheDirectory}tiles/background`;
|
|
|
|
|
|
const gridUrl = `${MAP_HOST}/tiles_nm/grid`;
|
|
const gridUrl = `${MAP_HOST}/tiles_nm/grid`;
|
|
const localGridDir = `${FileSystem.cacheDirectory}tiles/grid`;
|
|
const localGridDir = `${FileSystem.cacheDirectory}tiles/grid`;
|
|
@@ -61,6 +61,7 @@ const AnimatedMarker = Animated.createAnimatedComponent(Marker);
|
|
const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
const userId = storage.get('uid', StoreType.STRING);
|
|
const userId = storage.get('uid', StoreType.STRING);
|
|
const token = storage.get('token', StoreType.STRING);
|
|
const token = storage.get('token', StoreType.STRING);
|
|
|
|
+ const isOnline = getOnlineStatus();
|
|
|
|
|
|
const { mutateAsync } = fetchSeriesData();
|
|
const { mutateAsync } = fetchSeriesData();
|
|
|
|
|
|
@@ -119,11 +120,11 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
- setIsConnected(state.isConnected);
|
|
|
|
|
|
+ setIsConnected(isOnline as boolean);
|
|
});
|
|
});
|
|
|
|
|
|
return () => unsubscribe();
|
|
return () => unsubscribe();
|
|
- }, []);
|
|
|
|
|
|
+ }, [isOnline]);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
(async () => {
|
|
(async () => {
|
|
@@ -153,6 +154,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
latitudeDelta: any;
|
|
latitudeDelta: any;
|
|
longitudeDelta?: any;
|
|
longitudeDelta?: any;
|
|
}) => {
|
|
}) => {
|
|
|
|
+ if (!isOnline) return;
|
|
const currentZoom = Math.log2(360 / visibleMapArea.latitudeDelta);
|
|
const currentZoom = Math.log2(360 / visibleMapArea.latitudeDelta);
|
|
|
|
|
|
if (cancelTokenRef.current) {
|
|
if (cancelTokenRef.current) {
|
|
@@ -186,7 +188,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
(region: { properties: { id: any } }) => region.properties.id
|
|
(region: { properties: { id: any } }) => region.properties.id
|
|
);
|
|
);
|
|
|
|
|
|
- await mutateAsync(
|
|
|
|
|
|
+ isOnline && await mutateAsync(
|
|
{ regions: JSON.stringify(regionIds), token: String(token) },
|
|
{ regions: JSON.stringify(regionIds), token: String(token) },
|
|
{
|
|
{
|
|
onSuccess: (data) => {
|
|
onSuccess: (data) => {
|