diff --git a/package.json b/package.json index 07e3b38..9aa45f4 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "expo-constants": "~13.1.1", "expo-file-system": "~14.0.0", "expo-location": "~14.2.2", - "expo-updates": "~0.13.2", + "expo-updates": "~0.13.3", "graphql": "^15.4.0", "lodash": "^4.17.20", "moment": "^2.29.1", diff --git a/src/components/busArrivalDetails/BusArrivalDetails.tsx b/src/components/busArrivalDetails/BusArrivalDetails.tsx index b766b52..f472682 100644 --- a/src/components/busArrivalDetails/BusArrivalDetails.tsx +++ b/src/components/busArrivalDetails/BusArrivalDetails.tsx @@ -99,13 +99,13 @@ function BusArrivalDetails(props: any): JSX.Element { }, []); useEffect(() => { - if (route.params) { + if (!responseData && route.params) { const busStopCode = (route.params as any).busStopCode; getBusArrival({ variables: { busStopCode: busStopCode }, }); } - }, [route.params]); + }, [responseData, route.params]); useEffect(() => { if (data) { @@ -329,7 +329,7 @@ function BusArrivalDetails(props: any): JSX.Element { }); } - if (!loading) { + if (data) { setRefreshing(false); } }; diff --git a/src/components/busServiceRoutes/BusServiceRoutes.tsx b/src/components/busServiceRoutes/BusServiceRoutes.tsx index 0ac1f1d..7850187 100644 --- a/src/components/busServiceRoutes/BusServiceRoutes.tsx +++ b/src/components/busServiceRoutes/BusServiceRoutes.tsx @@ -96,13 +96,13 @@ function BusServiceRoutes(props: any): JSX.Element { }, []); useEffect(() => { - if (route.params) { + if (!responseData && route.params) { const busServiceNo = (route.params as any).busServiceNo; getBusRouteByBusServiceNo({ variables: { busServiceNo: busServiceNo }, }); } - }, [route.params]); + }, [responseData, route.params]); useEffect(() => { if (data) { @@ -130,7 +130,7 @@ function BusServiceRoutes(props: any): JSX.Element { }); } - if (!loading) { + if (data) { setRefreshing(false); } }; diff --git a/src/components/favourites/Favourites.tsx b/src/components/favourites/Favourites.tsx index 41cc2e3..5278861 100644 --- a/src/components/favourites/Favourites.tsx +++ b/src/components/favourites/Favourites.tsx @@ -107,14 +107,14 @@ function Favourites(props: any): JSX.Element { }, []); useEffect(() => { - if (Constants.installationId) { + if (!responseData && Constants.installationId) { getFavouritesByInstallationId({ variables: { installationId: Constants.installationId, }, }); } - }, [Constants.installationId]); + }, [responseData, Constants.installationId]); useEffect(() => { if (data) { @@ -123,16 +123,14 @@ function Favourites(props: any): JSX.Element { }, [data]); useEffect(() => { - if (deleteFavouritesResult.data) { - if (deleteFavouritesResult.data.deleteFavouritesById.status) { - setResponseData(null); - deleteFavouritesResult.client.clearStore(); - getFavouritesByInstallationId({ - variables: { - installationId: Constants.installationId, - }, - }); - } + if (deleteFavouritesResult.data && deleteFavouritesResult.data.deleteFavouritesById.status) { + setResponseData(null); + deleteFavouritesResult.client.clearStore(); + getFavouritesByInstallationId({ + variables: { + installationId: Constants.installationId, + }, + }); } }, [deleteFavouritesResult.data]); @@ -164,44 +162,42 @@ function Favourites(props: any): JSX.Element { ); } else { - if (responseData) { - if (responseData.getFavouritesByInstallationId) { - favouritesListDiv = responseData.getFavouritesByInstallationId.map((element: any, i: number) => { - const item = element.item; - - return ( - - - handleDeleteButtonClick(element.id)}> - - - - - {item.description} - {item.road_name} - - handleBusStopCodeClick(item.bus_stop_code)} - > - - {item.bus_stop_code} - + if (responseData && responseData.getFavouritesByInstallationId) { + favouritesListDiv = responseData.getFavouritesByInstallationId.map((element: any, i: number) => { + const item = element.item; + + return ( + + + handleDeleteButtonClick(element.id)}> + + - - handleOpenInMap(item.latitude, item.longitude)}> - Open in map - - + {item.description} + {item.road_name} + + handleBusStopCodeClick(item.bus_stop_code)} + > + + {item.bus_stop_code} + + + + + handleOpenInMap(item.latitude, item.longitude)}> + Open in map + + - - - + + - ); - }); - } + + ); + }); } } } @@ -247,7 +243,7 @@ function Favourites(props: any): JSX.Element { }, }); - if (!loading) { + if (data) { setRefreshing(false); } }; diff --git a/src/components/nearMe/NearMe.tsx b/src/components/nearMe/NearMe.tsx index 3510e8c..b079cdd 100644 --- a/src/components/nearMe/NearMe.tsx +++ b/src/components/nearMe/NearMe.tsx @@ -266,11 +266,8 @@ function NearMe(props: any): JSX.Element { setPageNumber(1); client?.clearStore(); setResponseData(null); - // getBusStopByLatLong({ - // variables: { latitude: latitude, longitude: longitude, pageNumber: pageNumber }, - // }); - if (!loading) { + if (data) { setRefreshing(false); } }; diff --git a/src/components/search/Search.tsx b/src/components/search/Search.tsx index bef5096..7c7c192 100644 --- a/src/components/search/Search.tsx +++ b/src/components/search/Search.tsx @@ -248,6 +248,7 @@ function Search(props: any): JSX.Element { setRecordData(null); setRecord2Data(null); setRecord3Data(null); + setRecord4Data(null); setRoadName(text); }; @@ -256,6 +257,7 @@ function Search(props: any): JSX.Element { setRecordData(null); setRecord2Data(null); setRecord3Data(null); + setRecord4Data(null); setPlaceName(text); }; @@ -264,6 +266,7 @@ function Search(props: any): JSX.Element { setRecordData(null); setRecord2Data(null); setRecord3Data(null); + setRecord4Data(null); setBusStopCode(text); }; @@ -517,11 +520,13 @@ function Search(props: any): JSX.Element { setRecordData(null); setRecord2Data(null); setRecord3Data(null); + setRecord4Data(null); if ( - !getBusStopByRoadNameResult.loading && - !getBusStopByDescriptionResult.loading && - !getBusStopByBusStopCodeResult.loading + !getBusStopByRoadNameResult.loading || + !getBusStopByDescriptionResult.loading || + !getBusStopByBusStopCodeResult.loading || + !getAllBusServiceResult.loading ) { setRefreshing(false); } diff --git a/yarn.lock b/yarn.lock index b04680d..8a076d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4784,10 +4784,10 @@ expo-updates-interface@~0.6.0: resolved "https://registry.yarnpkg.com/expo-updates-interface/-/expo-updates-interface-0.6.0.tgz#cef5250106e59572afdfcf245c534754c8c844ba" integrity sha512-oQcGTsE8mSkSxENPlWjZPGoJpt3RFDNPuO5d8shBDxBb4ZNH/W2ojavSFQMaLbNMoS0bYQQhzbRNEIBd306QMg== -expo-updates@~0.13.2: - version "0.13.2" - resolved "https://registry.yarnpkg.com/expo-updates/-/expo-updates-0.13.2.tgz#c96d664d8a97eb3af6841e46a137962b8bf06361" - integrity sha512-2ZthmyxYuN/c71y2oLNz9fdVXLf7ggxAw3Tfy+kwtGOTKNyOf/YoG+SwX7a0v+jZTJnuorEj5FuNf3wrniQ7+w== +expo-updates@~0.13.3: + version "0.13.3" + resolved "https://registry.yarnpkg.com/expo-updates/-/expo-updates-0.13.3.tgz#1e55ba2682de4633f2d1d0424078873868821361" + integrity sha512-aVO3Ha+vRGnkJbqlJMNoQn/p31DMnhZSGUs977ixhb0ff2xs530vf4/zVi4s635lkwuCd23++oga44Z4quKV/w== dependencies: "@expo/code-signing-certificates" "0.0.1" "@expo/config" "^6.0.14"