Skip to content

Commit ba1c2ef

Browse files
authored
Merge pull request #2110 from HSLdevcom/DT-2385
DT-2385: When user tries to print an itinerary with only walking mode, the application crashes
2 parents 2274194 + a98c076 commit ba1c2ef

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

app/component/PrintableItinerary.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ function TransferMap(props) {
128128
const previousLeg = props.originalLegs[props.index - 1];
129129

130130
let itineraryLine;
131-
if (!nextLeg) {
132-
itineraryLine = [previousLeg, props.legObj];
133-
} else if (nextLeg && nextLeg.intermediatePlace) {
131+
if ((!previousLeg && !nextLeg) || (nextLeg && nextLeg.intermediatePlace)) {
134132
itineraryLine = [props.legObj];
133+
} else if (!nextLeg) {
134+
itineraryLine = [previousLeg, props.legObj];
135135
} else {
136136
itineraryLine = [props.legObj, nextLeg];
137137
}
@@ -378,15 +378,16 @@ class PrintableItinerary extends React.Component {
378378
index={i}
379379
originalLegs={originalLegs}
380380
context={this.context}
381-
mapsLoaded={() => {
382-
this.setState({ mapsLoaded: this.state.mapsLoaded + 1 });
383-
if (
384-
this.state.mapsLoaded + 1 ===
385-
originalLegs.filter(o2 => o2.mode === 'WALK').length
386-
) {
387-
setTimeout(() => window.print(), 1000);
388-
}
389-
}}
381+
mapsLoaded={() =>
382+
this.setState({ mapsLoaded: this.state.mapsLoaded + 1 }, () => {
383+
if (
384+
this.state.mapsLoaded >=
385+
originalLegs.filter(o2 => o2.mode === 'WALK').length
386+
) {
387+
setTimeout(() => window.print(), 1000);
388+
}
389+
})
390+
}
390391
/>
391392
</div>
392393
);

0 commit comments

Comments
 (0)