Making sure gpx id is 'new' when importing a GPX as a new journey

This commit is contained in:
Eric van der Vlist 2023-04-15 18:25:27 +02:00
parent b38fdf49ad
commit 856cd7637e
2 changed files with 9 additions and 4 deletions

View File

@ -37,8 +37,8 @@ const GpxDialog: Component<{}> = (props) => {
dispatch({ action: 'getCurrentAccount' }).then((currentAccount: any) => { dispatch({ action: 'getCurrentAccount' }).then((currentAccount: any) => {
console.log({ caller: 'GpxDialog / currentAccount', currentAccount }); console.log({ caller: 'GpxDialog / currentAccount', currentAccount });
setCurrentAccount(currentAccount); setCurrentAccount(currentAccount);
setCurrentGpxId(currentAccount.currentGpxId); setCurrentGpxId(currentAccount.currentGpxId || 'new');
setSelectedGpxId(currentAccount.currentGpxId); setSelectedGpxId(currentAccount.currentGpxId || 'new');
}); });
const handleClickOpen = async () => { const handleClickOpen = async () => {

View File

@ -63,14 +63,19 @@ const ImportSingleFile: Component<Props> = ({ file: file }) => {
const [statsAndGpx, setStatsAndGpx] = createSignal<StatsAndGpx>(); const [statsAndGpx, setStatsAndGpx] = createSignal<StatsAndGpx>();
const [picture, setPicture] = createSignal<Picture>(); const [picture, setPicture] = createSignal<Picture>();
const [state, setState] = createSignal('init'); const [state, setState] = createSignal('init');
const [gpxId, setGpxId] = createSignal<string>(''); const [gpxId, setGpxId] = createSignal<string>('new');
createEffect(() => { createEffect(() => {
setGpxId(currentGpxId()); setGpxId(currentGpxId());
}); });
const parseGpx = (content: string) => { const parseGpx = (content: string) => {
const gpx = GPX.parse(content); const gpx = GPX.parse(content);
console.log({ caller: 'ImportSingleFile / JSON', gpxFile: file, gpx }); console.log({
caller: 'ImportSingleFile / JSON',
gpxFile: file,
gpx,
gpxId: gpxId(),
});
setStatsAndGpx({ gpx, stats: analyzeGpx(gpx) }); setStatsAndGpx({ gpx, stats: analyzeGpx(gpx) });
}; };