|
@@ -215,10 +215,10 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
}, [dareData]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (route.params?.id && route.params?.type && dareData) {
|
|
|
+ if (route.params?.id && route.params?.type && dareData && db1 && db2 && db3) {
|
|
|
handleFindRegion(route.params?.id, route.params?.type);
|
|
|
}
|
|
|
- }, [route, dareData]);
|
|
|
+ }, [route, dareData, db1, db2, db3]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (userInfo) {
|
|
@@ -493,6 +493,8 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
refreshDatabases();
|
|
|
});
|
|
|
|
|
|
+ setUserData({ type: 'countries', id: +countryId });
|
|
|
+
|
|
|
token &&
|
|
|
(await mutateCountriesData(
|
|
|
{ id: +countryId, token },
|
|
@@ -553,6 +555,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
zoomLevel < 7 && mapRef.current?.animateToRegion(region, 1000);
|
|
|
|
|
|
if (tableName === 'regions') {
|
|
|
+ setUserData({ type: 'nm', id: +id });
|
|
|
token &&
|
|
|
(await mutateUserData(
|
|
|
{ region_id: +id, token: String(token) },
|
|
@@ -575,6 +578,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
}
|
|
|
));
|
|
|
} else {
|
|
|
+ setUserData({ type: 'dare', id: +id });
|
|
|
token &&
|
|
|
(await mutateUserDataDare(
|
|
|
{ dare_id: +id, token: String(token) },
|
|
@@ -593,6 +597,9 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
|
|
|
const handleFindRegion = async (id: number, type: string) => {
|
|
|
cancelTokenRef.current = true;
|
|
|
+ if (!db1 || !db2 || !db3) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
const db = type === 'regions' ? db1 : type === 'countries' ? db3 : db2;
|
|
|
|
|
|
if (type === 'countries') {
|
|
@@ -609,6 +616,8 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
refreshDatabases();
|
|
|
});
|
|
|
|
|
|
+ setUserData({ type: 'countries', id: +id });
|
|
|
+
|
|
|
token &&
|
|
|
(await mutateCountriesData(
|
|
|
{ id: +id, token },
|
|
@@ -663,6 +672,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
mapRef.current?.animateToRegion(region, 1000);
|
|
|
|
|
|
if (type === 'regions') {
|
|
|
+ setUserData({ type: 'nm', id: +id });
|
|
|
token &&
|
|
|
(await mutateUserData(
|
|
|
{ region_id: +id, token: String(token) },
|
|
@@ -686,6 +696,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
}
|
|
|
));
|
|
|
} else {
|
|
|
+ setUserData({ type: 'dare', id: +id });
|
|
|
token &&
|
|
|
(await mutateUserDataDare(
|
|
|
{ dare_id: +id, token: String(token) },
|