فهرست منبع

un map mode fix

Viktoriia 1 هفته پیش
والد
کامیت
0f5cec0e36

+ 14 - 8
src/contexts/RegionContext.tsx

@@ -102,6 +102,7 @@ export const RegionProvider = ({ children }: { children: React.ReactNode }) => {
   const handleUpdateSlow = useCallback(
     async (id: number, v?: boolean, s11?: boolean, s31?: boolean, s101?: boolean) => {
       const updatedSlow: any = {
+        ...userData,
         type: 'countries',
         visited: true
       };
@@ -143,16 +144,21 @@ export const RegionProvider = ({ children }: { children: React.ReactNode }) => {
         updatedSlowData.s101 = !visitedValue ? false : s101;
       }
 
-      updateSlow(updatedSlowData);
-
-      await mutateCountriesData(
-        { id, token },
+      updateSlow(updatedSlowData,
         {
-          onSuccess: (data) => {
-            setUserData({ type: 'countries', id, ...data.data });
+          onSuccess: () => {
+            mutateCountriesData(
+              { id, token },
+              {
+                onSuccess: (data) => {
+                  setUserData({ type: 'countries', id, ...data.data });
+                }
+              }
+            );
           }
-        }
-      );
+        });
+
+      updatedSlow && setUserData(updatedSlow);
     },
     [userData, token]
   );

+ 6 - 3
src/modules/api/maps/queries/use-post-get-visited-countries-ids.tsx

@@ -10,14 +10,17 @@ export const usePostGetVisitedCountriesIdsQuery = (
   type: 'in' | 'by',
   year: number,
   uid: number,
-  enabled: boolean
+  enabled: boolean,
+  forceRefetch: number = 0
 ) => {
   return useQuery<PostGetVisitedIds, BaseAxiosError>({
-    queryKey: mapsQueryKeys.getVisitedCountriesIds(token, type, year, uid),
+    queryKey: [...mapsQueryKeys.getVisitedCountriesIds(token, type, year, uid), forceRefetch],
     queryFn: async () => {
       const response = await mapsApi.getVisitedCountriesIds(token, type, year, uid);
       return response.data;
     },
-    enabled
+    enabled,
+    staleTime: 0,
+    gcTime: 0,
   });
 };

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

@@ -360,7 +360,8 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
       regionsFilter.visitedLabel,
       regionsFilter.year,
       +userId,
-      type === 'countries' && !!userId && isConnected
+      type === 'countries' && !!userId && isConnected,
+      forceRefetch
     );
   const { data: visitedDareIds, refetch: refetchVisitedDare } = usePostGetVisitedDareIdsQuery(
     token,