Skip to content

Commit bfe0896

Browse files
Pass totalRoutes as prop to CoveredAreaMap instead of reading from store
Agent-Logs-Url: https://github.com/MobilityData/mobilitydatabase-web/sessions/b2b856c6-d6e9-4f2c-b3a4-104dd5c12915 Co-authored-by: Alessandro100 <18631060+Alessandro100@users.noreply.github.com>
1 parent 405825b commit bfe0896

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/app/components/CoveredAreaMap.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ import { GtfsVisualizationMap } from './GtfsVisualizationMap';
3737
import ZoomOutMapIcon from '@mui/icons-material/ZoomOutMap';
3838
import { useRemoteConfig } from '../context/RemoteConfigProvider';
3939
import { sendGAEvent } from '@next/third-parties/google';
40-
import {
41-
selectGtfsDatasetRoutesLoadingStatus,
42-
selectGtfsDatasetRoutesTotal,
43-
} from '../store/supporting-files-selectors';
40+
import { selectGtfsDatasetRoutesLoadingStatus } from '../store/supporting-files-selectors';
4441
import {
4542
getLatestGbfsVersion,
4643
type LatestDatasetLite,
@@ -60,6 +57,7 @@ interface CoveredAreaMapProps {
6057
boundingBox?: LngLatTuple[];
6158
latestDataset?: LatestDatasetLite;
6259
feed: AllFeedType;
60+
totalRoutes?: number;
6361
}
6462

6563
export const fetchGeoJson = async (
@@ -86,6 +84,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
8684
boundingBox,
8785
latestDataset,
8886
feed,
87+
totalRoutes,
8988
}) => {
9089
const t = useTranslations('feeds');
9190
const tCommon = useTranslations('common');
@@ -109,9 +108,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
109108
const routesJsonLoadingStatus = useSelector(
110109
selectGtfsDatasetRoutesLoadingStatus,
111110
);
112-
const routesTotal = useSelector(selectGtfsDatasetRoutesTotal);
113-
const hasNoRoutes =
114-
routesJsonLoadingStatus === 'loaded' && routesTotal === 0;
111+
const hasNoRoutes = totalRoutes !== undefined && totalRoutes === 0;
115112

116113
const getAndSetGeoJsonData = (urlToExtract: string): void => {
117114
setGeoJsonLoading(true);
@@ -187,7 +184,7 @@ const CoveredAreaMap: React.FC<CoveredAreaMapProps> = ({
187184
return;
188185
}
189186
setView('boundingBoxView');
190-
}, [feed, routesJsonLoadingStatus, routesTotal, boundingBox, geoJsonData]);
187+
}, [feed, routesJsonLoadingStatus, totalRoutes, boundingBox, geoJsonData]);
191188

192189
const handleViewChange = (
193190
_: React.MouseEvent<HTMLElement>,

src/app/screens/Feed/FeedView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ export default async function FeedView({
384384
boundingBox={boundingBox}
385385
latestDataset={latestDataset}
386386
feed={feed}
387+
totalRoutes={totalRoutes}
387388
/>
388389
)}
389390
<Box sx={{ width: { xs: '100%', md: '475px' } }}>

0 commit comments

Comments
 (0)