Viktoriia hai 14 horas
pai
achega
c1f0c18753
Modificáronse 1 ficheiros con 19 adicións e 2 borrados
  1. 19 2
      src/screens/InAppScreens/MapScreen/index.tsx

+ 19 - 2
src/screens/InAppScreens/MapScreen/index.tsx

@@ -303,6 +303,8 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
   const { data: countriesList } = useGetListCountriesQuery(isConnected);
   const { data: dareList } = useGetListDareQuery(isConnected);
 
+  const [usersCount, setUsersCount] = useState(0);
+
   const [tilesType, setTilesType] = useState({ label: 'NM regions', value: 0 });
   const tilesTypes = [
     { label: 'Blank', value: -1 },
@@ -463,9 +465,23 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
       if (!nomads || JSON.stringify(filteredNomads) !== JSON.stringify(nomads)) {
         setNomads(filteredNomads);
       }
+      if (usersOnMapCount && usersOnMapCount.count) {
+        setUsersCount(usersOnMapCount.count);
+      }
     }
   }, [usersLocation, showNomads, refreshInterval]);
 
+  useEffect(() => {
+    if (
+      usersOnMapCount &&
+      usersOnMapCount.count &&
+      !nomadsFilter.friends &&
+      !nomadsFilter.countries?.length
+    ) {
+      setUsersCount(usersOnMapCount.count);
+    }
+  }, [usersOnMapCount]);
+
   useEffect(() => {
     const loadCachedIcons = async () => {
       try {
@@ -677,6 +693,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
       {
         onSuccess: (data) => {
           if (data && data?.geojson) {
+            setUsersCount(data.geojson.features?.length);
             const filteredNomads: GeoJSON.FeatureCollection = {
               type: 'FeatureCollection',
               features: data.geojson.features.filter(
@@ -1989,9 +2006,9 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
                   text="Nomads"
                   active={showNomads || nomadsFilter.friends || nomadsFilter.countries?.length}
                 >
-                  {usersOnMapCount && usersOnMapCount?.count > 0 ? (
+                  {usersCount && usersCount > 0 ? (
                     <MessagesDot
-                      messagesCount={usersOnMapCount.count}
+                      messagesCount={usersCount}
                       fullNumber={true}
                       right={-10}
                       top={-8}