diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 09c27b2..34f0bdb 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -37,7 +37,7 @@ import Infos, { clickHandler } from '../infos'; import GpxDialog from '../gpx-dialog'; import GpxRecord from '../gpx-record'; import dispatch from '../../workers/dispatcher-main'; -import { isEqual } from 'lodash'; +import { debounce } from 'lodash'; const [getState, setState] = createSignal({ lon: 0, @@ -76,6 +76,11 @@ const Map: Component = () => { let target: HTMLDivElement; + const debouncedDbSetState = debounce((state: any) => { + console.log({ caller: 'Map / debouncedDbSetState', state }); + dispatch({ action: 'setState', params: state }); + }, 60000); + createEffect(async () => { console.log({ caller: 'Map / setState', @@ -90,7 +95,7 @@ const Map: Component = () => { rotation: +params.rotation, zoom: +params.zoom, }); - await dispatch({ action: 'setState', params: getState() }); + debouncedDbSetState(getState()); const map = getMap(); const layers = map?.getLayers();