mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
fix bugs
This commit is contained in:
@@ -221,7 +221,7 @@ export class GPXFile extends GPXTreeNode<Track>{
|
||||
}
|
||||
|
||||
reverse() {
|
||||
return this._reverse();
|
||||
return this._reverse(this.getEndTimestamp(), this.getStartTimestamp());
|
||||
}
|
||||
|
||||
reverseTrack(trackIndex: number) {
|
||||
@@ -349,7 +349,7 @@ export class Track extends GPXTreeNode<TrackSegment> {
|
||||
return produce(this, (draft) => {
|
||||
let og = getOriginal(draft); // Read as much as possible from the original object because it is faster
|
||||
let trkseg = og.trkseg.slice();
|
||||
trkseg[segmentIndex] = trkseg[segmentIndex]._reverse();
|
||||
trkseg[segmentIndex] = trkseg[segmentIndex]._reverse(trkseg[segmentIndex].getEndTimestamp(), trkseg[segmentIndex].getStartTimestamp());
|
||||
draft.trkseg = freeze(trkseg); // Pre-freeze the array, faster as well
|
||||
});
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
import * as Collapsible from '$lib/components/ui/collapsible';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-svelte';
|
||||
import { getContext, setContext } from 'svelte';
|
||||
import { getContext, onMount, setContext } from 'svelte';
|
||||
import { get, type Writable } from 'svelte/store';
|
||||
|
||||
export let id: string | number;
|
||||
@@ -18,15 +18,16 @@
|
||||
let fullId = `${parentId}.${id}`;
|
||||
setContext('collapsible-tree-parent-id', fullId);
|
||||
|
||||
open.update((value) => {
|
||||
if (!value.hasOwnProperty(fullId)) {
|
||||
value[fullId] = defaultState === 'open';
|
||||
onMount(() => {
|
||||
if (!get(open).hasOwnProperty(fullId)) {
|
||||
open.update((value) => {
|
||||
value[fullId] = defaultState === 'open';
|
||||
return value;
|
||||
});
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
export function openNode() {
|
||||
if (get(open)[fullId]) return;
|
||||
open.update((value) => {
|
||||
value[fullId] = true;
|
||||
return value;
|
||||
|
@@ -9,13 +9,15 @@
|
||||
};
|
||||
|
||||
let dragging: Writable<ListLevel | null> = writable(null);
|
||||
|
||||
let updating = false;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { GPXFile, Track, Waypoint, type AnyGPXTreeElement, type GPXTreeElement } from 'gpx';
|
||||
import { afterUpdate, getContext, onMount } from 'svelte';
|
||||
import Sortable from 'sortablejs/Sortable';
|
||||
import { fileObservers, getFileIds, settings, type GPXFileWithStatistics } from '$lib/db';
|
||||
import { getFileIds, settings, type GPXFileWithStatistics } from '$lib/db';
|
||||
import { get, writable, type Readable, type Writable } from 'svelte/store';
|
||||
import FileListNodeStore from './FileListNodeStore.svelte';
|
||||
import FileListNode from './FileListNode.svelte';
|
||||
@@ -46,6 +48,8 @@
|
||||
let orientation = getContext<'vertical' | 'horizontal'>('orientation');
|
||||
|
||||
function updateToSelection() {
|
||||
if (updating) return;
|
||||
updating = true;
|
||||
// Sortable updates selection
|
||||
let changed = getChangedIds();
|
||||
if (changed.length > 0) {
|
||||
@@ -60,9 +64,12 @@
|
||||
return $selection;
|
||||
});
|
||||
}
|
||||
updating = false;
|
||||
}
|
||||
|
||||
async function updateFromSelection() {
|
||||
function updateFromSelection() {
|
||||
if (updating) return;
|
||||
updating = true;
|
||||
// Selection updates sortable
|
||||
let changed = getChangedIds();
|
||||
for (let id of changed) {
|
||||
@@ -79,6 +86,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
updating = false;
|
||||
}
|
||||
|
||||
$: if ($selection) {
|
||||
@@ -198,10 +206,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
let firstUpdateAfterMount = false;
|
||||
onMount(() => {
|
||||
createSortable();
|
||||
firstUpdateAfterMount = true;
|
||||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
@@ -220,10 +226,7 @@
|
||||
});
|
||||
|
||||
syncFileOrder();
|
||||
if (firstUpdateAfterMount) {
|
||||
firstUpdateAfterMount = false;
|
||||
updateFromSelection();
|
||||
}
|
||||
updateFromSelection();
|
||||
});
|
||||
|
||||
function getChangedIds() {
|
||||
|
@@ -272,7 +272,7 @@ export class GPXLayer {
|
||||
}
|
||||
|
||||
let item = undefined;
|
||||
if (get(verticalFileView) && file.children.length > 1) { // Select inner item
|
||||
if (get(verticalFileView) && file.getSegments().length > 1) { // Select inner item
|
||||
let trackIndex = e.features[0].properties.trackIndex;
|
||||
let segmentIndex = e.features[0].properties.segmentIndex;
|
||||
item = file.children[trackIndex].children.length > 1 ? new ListTrackSegmentItem(this.fileId, trackIndex, segmentIndex) : new ListTrackItem(this.fileId, trackIndex);
|
||||
|
@@ -63,7 +63,7 @@ async function getRoute(points: Coordinates[], brouterProfile: string, privateRo
|
||||
const latIdx = messages[0].indexOf("Latitude");
|
||||
const tagIdx = messages[0].indexOf("WayTags");
|
||||
let messageIdx = 1;
|
||||
let surface = getSurface(messages[messageIdx][tagIdx]);
|
||||
let surface = messageIdx < messages.length ? getSurface(messages[messageIdx][tagIdx]) : "unknown";
|
||||
|
||||
for (let i = 0; i < coordinates.length; i++) {
|
||||
let coord = coordinates[i];
|
||||
|
@@ -402,7 +402,7 @@ export class RoutingControls {
|
||||
dbUtils.applyToFile(this.fileId, (file) => {
|
||||
let segment = original(file).getSegment(lastAnchor.trackIndex, lastAnchor.segmentIndex);
|
||||
let newSegment = segment.clone();
|
||||
newSegment = newSegment.reverse(segment.getEndTimestamp(), segment.getEndTimestamp());
|
||||
newSegment = newSegment._reverse(segment.getEndTimestamp(), segment.getEndTimestamp());
|
||||
return file.replaceTrackPoints(lastAnchor.trackIndex, lastAnchor.segmentIndex, segment.trkpt.length, segment.trkpt.length, newSegment.trkpt.map((point) => point));
|
||||
});
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import { _ } from 'svelte-i18n';
|
||||
import type { GPXLayer } from '$lib/components/gpx-layer/GPXLayer';
|
||||
import { dbUtils, fileObservers } from './db';
|
||||
import { applyToOrderedSelectedItemsFromFile, selectFile, selection } from '$lib/components/file-list/Selection';
|
||||
import { ListFileItem, ListWaypointItem } from '$lib/components/file-list/FileList';
|
||||
import { ListFileItem, ListWaypointItem, ListWaypointsItem } from '$lib/components/file-list/FileList';
|
||||
import type { RoutingControls } from '$lib/components/toolbar/tools/routing/RoutingControls';
|
||||
|
||||
export const map = writable<mapboxgl.Map | null>(null);
|
||||
@@ -24,7 +24,7 @@ function updateGPXData() {
|
||||
if (stats) {
|
||||
let first = true;
|
||||
items.forEach((item) => {
|
||||
if (!(item instanceof ListWaypointItem) || first) {
|
||||
if (!(item instanceof ListWaypointItem || item instanceof ListWaypointsItem) || first) {
|
||||
statistics.mergeWith(stats.getStatisticsFor(item));
|
||||
first = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user