Refreshing GPX list after importing a new GPX.

This commit is contained in:
Eric van der Vlist 2022-11-27 18:24:17 +01:00
parent 37fd31a040
commit 6c2573ba8b
6 changed files with 16 additions and 12 deletions

View File

@ -9,8 +9,7 @@ interface Props {
map: () => OlMap | null;
}
export const AllGpxes: Component<Props> = ({ map }) => {
const [allGpxIds] = createResource(
const [allGpxIds, { refetch }] = createResource(
async () =>
await dispatch({
action: 'getAllGpxes',
@ -18,6 +17,7 @@ export const AllGpxes: Component<Props> = ({ map }) => {
})
);
export const AllGpxes: Component<Props> = ({ map }) => {
createEffect(() => {
console.log({ caller: 'AllGpxes', allGpxes: allGpxIds(), map: map() });
});
@ -34,3 +34,4 @@ export const AllGpxes: Component<Props> = ({ map }) => {
};
export default AllGpxes;
export { refetch };

View File

@ -1 +1 @@
export { default } from './AllGpxes';
export { default, refetch as refetchGpxList } from './AllGpxes';

View File

@ -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
);

View File

@ -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(
() => (

View File

@ -19,6 +19,8 @@ export const init = () => {
dispatcherQueue.queue.get(id)(null, payload);
dispatcherQueue.queue.delete(id);
};
dispatch({ action: 'initDb' });
};
const dispatch = (

View File

@ -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[<keyof typeof actions>payload.action](
payload.params
);