diff --git a/src/components/all-gpxes/AllGpxes.tsx b/src/components/all-gpxes/AllGpxes.tsx index 2ffe6ac..e6edf37 100644 --- a/src/components/all-gpxes/AllGpxes.tsx +++ b/src/components/all-gpxes/AllGpxes.tsx @@ -9,15 +9,15 @@ interface Props { map: () => OlMap | null; } -export const AllGpxes: Component = ({ map }) => { - const [allGpxIds] = createResource( - async () => - await dispatch({ - action: 'getAllGpxes', - params: {}, - }) - ); +const [allGpxIds, { refetch }] = createResource( + async () => + await dispatch({ + action: 'getAllGpxes', + params: {}, + }) +); +export const AllGpxes: Component = ({ map }) => { createEffect(() => { console.log({ caller: 'AllGpxes', allGpxes: allGpxIds(), map: map() }); }); @@ -34,3 +34,4 @@ export const AllGpxes: Component = ({ map }) => { }; export default AllGpxes; +export { refetch }; diff --git a/src/components/all-gpxes/index.ts b/src/components/all-gpxes/index.ts index 540dbdb..873bb3d 100644 --- a/src/components/all-gpxes/index.ts +++ b/src/components/all-gpxes/index.ts @@ -1 +1 @@ -export { default } from './AllGpxes'; +export { default, refetch as refetchGpxList } from './AllGpxes'; diff --git a/src/components/gpx-import/GpxImport.tsx b/src/components/gpx-import/GpxImport.tsx index a0bc688..b84d45e 100644 --- a/src/components/gpx-import/GpxImport.tsx +++ b/src/components/gpx-import/GpxImport.tsx @@ -9,6 +9,7 @@ import css from './GpxImport.module.css'; import { findStartTime } from '../../lib/gpx'; import dispatch from '../../workers/dispatcher-main'; import { intToGpxId } from '../../lib/ids'; +import { refetchGpxList } from '../all-gpxes'; const GpxImport: Component = () => { const onChangeHandler = (event: any) => { @@ -39,6 +40,7 @@ const GpxImport: Component = () => { }, }, }); + refetchGpxList(); }, false ); diff --git a/src/index.tsx b/src/index.tsx index 4b72bc1..59c5eea 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,8 +1,8 @@ /* @refresh reload */ import { render } from 'solid-js/web'; import { Router, hashIntegration } from '@solidjs/router'; + import App from './App'; -import dispatch from './workers/dispatcher-main'; /* // See https://stackoverflow.com/questions/71538643/property-wakelock-does-not-exist-on-type-navigator const requestWakeLock = async () => { @@ -32,8 +32,6 @@ const handleVisibilityChange = () => { document.addEventListener('visibilitychange', handleVisibilityChange, false); requestWakeLock(); */ -// Init the database -dispatch({ action: 'initDb' }); render( () => ( diff --git a/src/workers/dispatcher-main.ts b/src/workers/dispatcher-main.ts index 2fc0b7c..4e035a8 100644 --- a/src/workers/dispatcher-main.ts +++ b/src/workers/dispatcher-main.ts @@ -19,6 +19,8 @@ export const init = () => { dispatcherQueue.queue.get(id)(null, payload); dispatcherQueue.queue.delete(id); }; + + dispatch({ action: 'initDb' }); }; const dispatch = ( diff --git a/src/workers/dispatcher-worker.ts b/src/workers/dispatcher-worker.ts index 0c7d9d3..b7e423a 100644 --- a/src/workers/dispatcher-worker.ts +++ b/src/workers/dispatcher-worker.ts @@ -33,6 +33,7 @@ onmessage = async function (e) { const { id, payload } = e.data; var returnValue: any = 'unknownAction'; if (payload.action in actions) { + console.log({ caller: 'dispatcher-worker / awaiting', id, payload }); returnValue = await actions[payload.action]( payload.params );