Skip to content

Commit 25a2df5

Browse files
authored
Merge pull request #505 from HSLdevcom/DT-6951
DT-6951 Fix stop monitor crashing when incorrect url
2 parents 4459031 + 813a2d8 commit 25a2df5

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/ui/Monitor.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ConfigContext, MonitorContext } from '../contexts';
1010
import { stopsAndStationsFromViews } from '../util/monitorUtils';
1111
import { getStopIcon } from '../util/stopCardUtil';
1212
import MonitorMapContainer from '../MonitorMapContainer';
13+
import NoMonitorsFound from './NoMonitorsFound';
1314

1415
const getWindowDimensions = () => {
1516
const { innerWidth: width, innerHeight: height } = window;
@@ -126,9 +127,25 @@ const Monitor: FC<IProps> = ({
126127
});
127128
})
128129
.flat();
129-
stopsForMap.forEach(c => {
130-
c.coords.flat();
131-
});
130+
131+
if (!stopsForMap.length) {
132+
return (
133+
<div
134+
style={style}
135+
className={cx('main-content-container', {
136+
preview: isPreview,
137+
portrait: !isLandscapeByLayout,
138+
})}
139+
onMouseMove={() => {
140+
setShowOverlay(true);
141+
clearTimeout(to);
142+
to = setTimeout(() => setShowOverlay(false), 3000);
143+
}}
144+
>
145+
<NoMonitorsFound />
146+
</div>
147+
);
148+
}
132149
return (
133150
<div
134151
style={style}

src/ui/MonitorTitleBar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ const MonitorTitlebar: FC<IProps> = ({
2626
const lat =
2727
view.type === 'map'
2828
? view.stops[0].coords[0]
29-
: view.columns.left.stops[0].lat;
29+
: view.columns.left.stops[0]?.lat;
3030
const lon =
3131
view.type === 'map'
3232
? view.stops[0].coords[1]
33-
: view.columns.left.stops[0].lon;
33+
: view.columns.left.stops[0]?.lon;
3434

3535
const showWeather = !isMultiDisplay && isLandscape && lat && lon;
3636

0 commit comments

Comments
 (0)