|
@@ -72,6 +72,7 @@ import {
|
|
|
usePostUpdateLocationMutation
|
|
|
} from '@api/location';
|
|
|
import UserItem from './UserItem';
|
|
|
+import { useConnection } from 'src/contexts/ConnectionContext';
|
|
|
|
|
|
const defaultUserAvatar = require('assets/icon-user-share-location-solid.png');
|
|
|
const logo = require('assets/logo-ua.png');
|
|
@@ -256,9 +257,12 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
const userId = storage.get('uid', StoreType.STRING) as string;
|
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
|
|
|
|
- const { data: regionsList } = useGetListRegionsQuery(true);
|
|
|
- const { data: countriesList } = useGetListCountriesQuery(true);
|
|
|
- const { data: dareList } = useGetListDareQuery(true);
|
|
|
+ const [isConnected, setIsConnected] = useState<boolean>(true);
|
|
|
+ const netInfo = useConnection();
|
|
|
+
|
|
|
+ const { data: regionsList } = useGetListRegionsQuery(isConnected);
|
|
|
+ const { data: countriesList } = useGetListCountriesQuery(isConnected);
|
|
|
+ const { data: dareList } = useGetListDareQuery(isConnected);
|
|
|
|
|
|
const [tilesType, setTilesType] = useState({ label: 'NM regions', value: 0 });
|
|
|
const tilesTypes = [
|
|
@@ -280,7 +284,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
const [showNomads, setShowNomads] = useState(
|
|
|
(storage.get('showNomads', StoreType.BOOLEAN) as boolean) ?? false
|
|
|
);
|
|
|
- const { data: locationSettings, refetch } = usePostGetSettingsQuery(token, !!token);
|
|
|
+ const { data: locationSettings, refetch } = usePostGetSettingsQuery(token, !!token && isConnected);
|
|
|
const { mutateAsync: updateLocation } = usePostUpdateLocationMutation();
|
|
|
const { data: visitedRegionIds, refetch: refetchVisitedRegions } =
|
|
|
usePostGetVisitedRegionsIdsQuery(
|
|
@@ -288,7 +292,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
regionsFilter.visitedLabel,
|
|
|
regionsFilter.year,
|
|
|
+userId,
|
|
|
- type === 'regions' && !!userId
|
|
|
+ type === 'regions' && !!userId && isConnected
|
|
|
);
|
|
|
const { data: visitedCountryIds, refetch: refetchVisitedCountries } =
|
|
|
usePostGetVisitedCountriesIdsQuery(
|
|
@@ -296,15 +300,15 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
regionsFilter.visitedLabel,
|
|
|
regionsFilter.year,
|
|
|
+userId,
|
|
|
- type === 'countries' && !!userId
|
|
|
+ type === 'countries' && !!userId && isConnected
|
|
|
);
|
|
|
const { data: visitedDareIds, refetch: refetchVisitedDare } = usePostGetVisitedDareIdsQuery(
|
|
|
token,
|
|
|
+userId,
|
|
|
- type === 'dare' && !!userId
|
|
|
+ type === 'dare' && !!userId && isConnected
|
|
|
);
|
|
|
- const { data: visitedSeriesIds } = usePostGetVisitedSeriesIdsQuery(token, !!userId);
|
|
|
- const { data: seriesIcons } = useGetIconsQuery(true);
|
|
|
+ const { data: visitedSeriesIds } = usePostGetVisitedSeriesIdsQuery(token, !!userId && isConnected);
|
|
|
+ const { data: seriesIcons } = useGetIconsQuery(isConnected);
|
|
|
const userInfo = storage.get('currentUserData', StoreType.STRING) as string;
|
|
|
const { mutateAsync: mutateUserData } = fetchUserData();
|
|
|
const { mutateAsync: mutateUserDataDare } = fetchUserDataDare();
|
|
@@ -336,7 +340,6 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
id: null
|
|
|
});
|
|
|
|
|
|
- const [isConnected, setIsConnected] = useState<boolean | null>(true);
|
|
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
|
const [search, setSearch] = useState('');
|
|
|
const { data: searchData } = useGetUniversalSearch(search, search.length > 0);
|
|
@@ -366,12 +369,18 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
const [nomads, setNomads] = useState<GeoJSON.FeatureCollection | null>(null);
|
|
|
const { data: usersLocation, refetch: refetchUsersLocation } = usePostGetUsersLocationQuery(
|
|
|
token,
|
|
|
- !!token && showNomads && Boolean(location)
|
|
|
+ !!token && showNomads && Boolean(location) && isConnected
|
|
|
);
|
|
|
const [selectedUser, setSelectedUser] = useState<any>(null);
|
|
|
|
|
|
const processedImages = useRef(new Set<string>());
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (netInfo && netInfo.isConnected !== null) {
|
|
|
+ setIsConnected(netInfo.isConnected);
|
|
|
+ }
|
|
|
+ }, [netInfo]);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (!showNomads) {
|
|
|
setNomads(null);
|