better gpx route error handling

This commit is contained in:
Fedor Katurov 2020-01-24 17:00:23 +07:00
parent e995b46641
commit 3ffba24994
2 changed files with 19 additions and 13 deletions

View file

@ -384,13 +384,15 @@ function* uploadGpx({ file }: ReturnType<typeof editorUploadGpx>) {
editorSetGpx({
list: [
...list,
...gpx.map(item => ({
enabled: true,
latlngs: item.latlngs,
color: getRandomColor(),
name: item.name || `Track #${list.length + 1}`,
id: uuid() as string,
})),
...gpx
.filter(item => item.latlngs && item.latlngs.length)
.map(item => ({
enabled: true,
latlngs: item.latlngs,
color: getRandomColor(),
name: item.name || `Track #${list.length + 1}`,
id: uuid() as string,
})),
],
})
);