Browse Source

small fix

Viktoriia 2 days ago
parent
commit
89e0943e15
1 changed files with 15 additions and 6 deletions
  1. 15 6
      src/screens/InAppScreens/MapScreen/index.tsx

+ 15 - 6
src/screens/InAppScreens/MapScreen/index.tsx

@@ -439,7 +439,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
 
   const [didFinishLoadingStyle, setDidFinishLoadingStyle] = useState(false);
 
-  const { isPremium } = useSubscription();
+  const { isPremium, loading } = useSubscription();
 
   useEffect(() => {
     if (netInfo && netInfo.isConnected !== null) {
@@ -581,6 +581,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
 
   useEffect(() => {
     const savedFilterSettings = storage.get('filterSettings', StoreType.STRING) as string;
+    const storageShowNomads = storage.get('showNomads', StoreType.BOOLEAN) as boolean;
     if (savedFilterSettings) {
       const filterSettings = JSON.parse(savedFilterSettings);
       setTilesType(filterSettings.tilesType);
@@ -592,7 +593,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
             : 'by',
         year: filterSettings.selectedYear?.value ?? moment().year()
       });
-      setShowNomads(filterSettings.showNomads ?? false);
+      setShowNomads(storageShowNomads ?? false);
       setNomadsFilter({
         friends: filterSettings.nomadsFilter ? filterSettings.nomadsFilter.friends : 0,
         trusted: filterSettings.nomadsFilter ? filterSettings.nomadsFilter.trusted : 0,
@@ -678,7 +679,15 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
   }, [dareVisited]);
 
   useEffect(() => {
-    if (!isPremium || !token || showNomads) return;
+    if (loading) return;
+
+    if (
+      !isPremium ||
+      !token ||
+      showNomads ||
+      (!nomadsFilter.friends && !nomadsFilter.countries?.length)
+    )
+      return;
     const countriesFilter = nomadsFilter.countries
       ? nomadsFilter.countries.map((country: any) => country.country)
       : [];
@@ -713,7 +722,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
         }
       }
     );
-  }, [nomadsFilter]);
+  }, [nomadsFilter, loading]);
 
   useEffect(() => {
     if (!seriesFilter.visible) {
@@ -813,7 +822,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
         // if (status === Location.PermissionStatus.GRANTED) {
         //   await startBackgroundLocationUpdates();
         // } else {
-          await stopBackgroundLocationUpdates();
+        await stopBackgroundLocationUpdates();
         // }
       } else {
         // await startBackgroundLocationUpdates();
@@ -1101,7 +1110,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
           // if (status === Location.PermissionStatus.GRANTED) {
           //   await startBackgroundLocationUpdates();
           // } else {
-            await stopBackgroundLocationUpdates();
+          await stopBackgroundLocationUpdates();
           // }
         } else {
           await startBackgroundLocationUpdates();