Bug fix when creating the first gpx.

This commit is contained in:
Eric van der Vlist 2023-02-13 20:57:30 +01:00
parent 51ab7c38e0
commit 1d5d158f8c
4 changed files with 8 additions and 10 deletions

View File

@ -23,6 +23,11 @@ const GpxChooser: Component<Props> = (props: Props) => {
action: 'getAllGpxesWithSummary', action: 'getAllGpxesWithSummary',
}, },
(error, result) => { (error, result) => {
console.log({
caller: 'GpxChooser / getAllGpxesWithSummary',
error,
result,
});
if (!error) { if (!error) {
setAllGpxes([ setAllGpxes([
{ id: 'new', name: t('newGpx'), creator: 'dyomedea' }, { id: 'new', name: t('newGpx'), creator: 'dyomedea' },

View File

@ -24,7 +24,7 @@ const GpxDialog: Component<{}> = (props) => {
console.log({ caller: 'GpxDialog', currentGpxId: currentGpxId() }); console.log({ caller: 'GpxDialog', currentGpxId: currentGpxId() });
const fetchGpx = (gpxId: string) => { const fetchGpx = (gpxId: string) => {
if (gpxId === 'new') { if (gpxId === 'new' || !gpxId) {
return newEmptyGpx(); return newEmptyGpx();
} }
const newGpx = peekCachedSignal({ const newGpx = peekCachedSignal({
@ -43,9 +43,7 @@ const GpxDialog: Component<{}> = (props) => {
const handleClickOpen = async () => { const handleClickOpen = async () => {
setOpen(true); setOpen(true);
if (currentGpxId() !== '') { setGpx(fetchGpx(currentGpxId()) as Gpx);
setGpx(fetchGpx(currentGpxId()) as Gpx);
}
console.log({ console.log({
caller: 'GpxDialog / handleClickOpen', caller: 'GpxDialog / handleClickOpen',
currentGpxId: currentGpxId(), currentGpxId: currentGpxId(),

View File

@ -1,17 +1,12 @@
import { import {
Component, Component,
createEffect, createEffect,
createResource,
createSignal,
For, For,
onCleanup, onCleanup,
Suspense, Suspense,
} from 'solid-js'; } from 'solid-js';
import OlMap from 'ol/Map';
import dispatch, { cancelDispatch } from '../../workers/dispatcher-main';
import getUri from '../../lib/ids';
import Trkseg from '../trkseg'; import Trkseg from '../trkseg';
import VectorSource from 'ol/source/Vector'; import VectorSource from 'ol/source/Vector';

View File

@ -421,7 +421,7 @@ export const putGpx = async (params: any) => {
let { id, gpx } = params; let { id, gpx } = params;
try { try {
if (id === 'new') { if (id === 'new' || !id) {
const date = !!gpx.metadata.time const date = !!gpx.metadata.time
? new Date(gpx.metadata.time) ? new Date(gpx.metadata.time)
: new Date(); : new Date();