From 2f362916da1c2c5a35c42e4b56f239f41cfb8b2e Mon Sep 17 00:00:00 2001 From: evlist Date: Mon, 7 Nov 2022 17:04:02 +0100 Subject: [PATCH] Trying to save a simple GPX. --- src/App.tsx | 1 + src/db/gpx.test.ts | 24 ++++++++++++------------ src/db/gpx.ts | 26 +++++++++++++------------- src/workers/dispatcher-worker.ts | 3 ++- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index acf75a8..f81b859 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -95,6 +95,7 @@ export const setCenterAtom = atom(null, (get, set, center: geoPoint) => { // initDb(db); dispatch({ action: 'initDb' }); +dispatch({ action: 'putNewGpx', params: 'gpxid' }); /** * diff --git a/src/db/gpx.test.ts b/src/db/gpx.test.ts index e6ce094..78850f9 100644 --- a/src/db/gpx.test.ts +++ b/src/db/gpx.test.ts @@ -37,21 +37,21 @@ describe('The gpx module', () => { 'xsi:schemaLocation': 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd', }, - extensions: undefined, + extensions: '', metadata: { - author: undefined, - bounds: undefined, - copyright: undefined, - desc: undefined, - extensions: undefined, - keywords: undefined, - link: undefined, - name: undefined, + author: '', + bounds: '', + copyright: '', + desc: '', + extensions: '', + keywords: '', + link: '', + name: '', time: '1970-01-01T00:00:00.000Z', }, - rte: undefined, - trk: undefined, - wpt: undefined, + rte: [], + trk: [], + wpt: [], }, type: 'gpx', }); diff --git a/src/db/gpx.ts b/src/db/gpx.ts index ffd2957..a5f1574 100644 --- a/src/db/gpx.ts +++ b/src/db/gpx.ts @@ -20,20 +20,20 @@ const emptyGpx: Gpx = { 'xmlns:dyo': 'http://xmlns.dyomedea.com/', }, metadata: { - name: undefined, - desc: undefined, - author: undefined, - copyright: undefined, - link: undefined, - time: undefined, - keywords: undefined, - bounds: undefined, - extensions: undefined, + name: '', + desc: '', + author: '', + copyright: '', + link: '', + time: '', + keywords: '', + bounds: '', + extensions: '', }, - wpt: undefined, - rte: undefined, - trk: undefined, - extensions: undefined, + wpt: [], + rte: [], + trk: [], + extensions: '', }; export const putNewGpx = (id: string) => { diff --git a/src/workers/dispatcher-worker.ts b/src/workers/dispatcher-worker.ts index 4ff2eee..7259d05 100644 --- a/src/workers/dispatcher-worker.ts +++ b/src/workers/dispatcher-worker.ts @@ -1,8 +1,9 @@ import { initDb } from '../db'; +import { putNewGpx } from '../db/gpx'; const self = globalThis as unknown as SharedWorkerGlobalScope; -const actions = { initDb }; +const actions = { initDb, putNewGpx }; self.onconnect = function (e) { var port = e.ports[0];