{#if $gpxStatistics.global.time.moving === 0 || $gpxStatistics.global.time.moving === undefined}
@@ -324,9 +332,9 @@
ratio = $gpxStatistics.global.speed.moving / effectiveSpeed;
}
- let item = $selection.getSelected()[0];
+ let item = selection.value.getSelected()[0];
let fileId = item.getFileId();
- dbUtils.applyToFile(fileId, (file) => {
+ fileActionManager.applyToFile(fileId, (file) => {
if (item instanceof ListFileItem) {
if (artificial || !$gpxStatistics.global.time.moving) {
file.createArtificialTimestamps(
diff --git a/website/src/lib/components/toolbar/tools/routing/Routing.svelte b/website/src/lib/components/toolbar/tools/routing/Routing.svelte
index f172729b..9e21b561 100644
--- a/website/src/lib/components/toolbar/tools/routing/Routing.svelte
+++ b/website/src/lib/components/toolbar/tools/routing/Routing.svelte
@@ -21,65 +21,75 @@
SquareArrowUpLeft,
SquareArrowOutDownRight,
} from '@lucide/svelte';
-
- import { map, newGPXFile, routingControls, selectFileWhenLoaded } from '$lib/stores';
- import { dbUtils, getFile, getFileIds, settings } from '$lib/db';
- import { brouterProfiles } from '$lib/components/toolbar/tools/routing/routing.svelte';
-
+ import { brouterProfiles } from '$lib/components/toolbar/tools/routing/utils.svelte';
import { i18n } from '$lib/i18n.svelte';
- import { RoutingControls } from './RoutingControls';
- import mapboxgl from 'mapbox-gl';
- import { fileObservers } from '$lib/db';
+ // import { RoutingControls } from './RoutingControls';
import { slide } from 'svelte/transition';
- import { getOrderedSelection, selection } from '$lib/components/file-list/Selection';
import {
ListFileItem,
ListRootItem,
ListTrackItem,
ListTrackSegmentItem,
type ListItem,
- } from '$lib/components/file-list/FileList';
+ } from '$lib/components/file-list/file-list';
import { getURLForLanguage, resetCursor, setCrosshairCursor } from '$lib/utils';
import { onDestroy, onMount } from 'svelte';
import { TrackPoint } from 'gpx';
+ import { settings } from '$lib/logic/settings.svelte';
+ import { map } from '$lib/components/map/utils.svelte';
+ import { fileStateCollection } from '$lib/logic/file-state.svelte';
+ import { selection } from '$lib/logic/selection.svelte';
+ import { fileActions, getFileIds, newGPXFile } from '$lib/logic/file-actions.svelte';
+
+ let {
+ minimized = $bindable(false),
+ minimizable = true,
+ popup = undefined,
+ popupElement = undefined,
+ class: className = '',
+ }: {
+ minimized?: boolean;
+ minimizable?: boolean;
+ popup?: mapboxgl.Popup;
+ popupElement?: HTMLDivElement;
+ class?: string;
+ } = $props();
- export let minimized = false;
- export let minimizable = true;
- export let popup: mapboxgl.Popup | undefined = undefined;
- export let popupElement: HTMLElement | undefined = undefined;
let selectedItem: ListItem | null = null;
const { privateRoads, routing, routingProfile } = settings;
- $: if ($map && popup && popupElement) {
- // remove controls for deleted files
- routingControls.forEach((controls, fileId) => {
- if (!$fileObservers.has(fileId)) {
- controls.destroy();
- routingControls.delete(fileId);
+ // $: if (map && popup && popupElement) {
+ // // remove controls for deleted files
+ // routingControls.forEach((controls, fileId) => {
+ // if (!$fileObservers.has(fileId)) {
+ // controls.destroy();
+ // routingControls.delete(fileId);
- if (selectedItem && selectedItem.getFileId() === fileId) {
- selectedItem = null;
- }
- } else if ($map !== controls.map) {
- controls.updateMap($map);
- }
- });
- // add controls for new files
- $fileObservers.forEach((file, fileId) => {
- if (!routingControls.has(fileId)) {
- routingControls.set(
- fileId,
- new RoutingControls($map, fileId, file, popup, popupElement)
- );
- }
- });
- }
+ // if (selectedItem && selectedItem.getFileId() === fileId) {
+ // selectedItem = null;
+ // }
+ // } else if ($map !== controls.map) {
+ // controls.updateMap($map);
+ // }
+ // });
+ // // add controls for new files
+ // fileStateCollection.files.forEach((file, fileId) => {
+ // if (!routingControls.has(fileId)) {
+ // routingControls.set(
+ // fileId,
+ // new RoutingControls($map, fileId, file, popup, popupElement)
+ // );
+ // }
+ // });
+ // }
- $: validSelection = $selection.hasAnyChildren(new ListRootItem(), true, ['waypoints']);
+ let validSelection = $derived(
+ selection.value.hasAnyChildren(new ListRootItem(), true, ['waypoints'])
+ );
function createFileWithPoint(e: any) {
- if ($selection.size === 0) {
+ if (selection.value.size === 0) {
let file = newGPXFile();
file.replaceTrackPoints(0, 0, 0, 0, [
new TrackPoint({
@@ -90,22 +100,22 @@
}),
]);
file._data.id = getFileIds(1)[0];
- dbUtils.add(file);
- selectFileWhenLoaded(file._data.id);
+ fileActions.add(file);
+ // selectFileWhenLoaded(file._data.id);
}
}
onMount(() => {
- setCrosshairCursor();
- $map?.on('click', createFileWithPoint);
+ // setCrosshairCursor();
+ map.value?.on('click', createFileWithPoint);
});
onDestroy(() => {
- resetCursor();
- $map?.off('click', createFileWithPoint);
+ // resetCursor();
+ map.value?.off('click', createFileWithPoint);
- routingControls.forEach((controls) => controls.destroy());
- routingControls.clear();
+ // routingControls.forEach((controls) => controls.destroy());
+ // routingControls.clear();
});
@@ -116,11 +126,11 @@
{:else}
-