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',
},
(error, result) => {
console.log({
caller: 'GpxChooser / getAllGpxesWithSummary',
error,
result,
});
if (!error) {
setAllGpxes([
{ id: 'new', name: t('newGpx'), creator: 'dyomedea' },

View File

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

View File

@ -1,17 +1,12 @@
import {
Component,
createEffect,
createResource,
createSignal,
For,
onCleanup,
Suspense,
} 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 VectorSource from 'ol/source/Vector';

View File

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