Badge the exception (not yet cached) instead of the near-universal case

GpxStore#save converts eagerly, so "cached" is true for nearly every
file in the tree already — badging that was just noise. Flipped to
PENDING_ICON, shown only for the rare case: a .gpx/.fit dropped
straight into data/gpx/ on the filesystem, bypassing the app, and not
yet opened.

Also add an explicit download button next to delete (DOWNLOAD_ICON) —
the file name itself has been a download link since the last commit,
but isn't obviously clickable at a glance.
This commit is contained in:
randy committed 2026-09-07 22:59:02 +02:00
1 parent cd92dadf6a
commit 12635a48c3
4 files changed
+73 -26

No files matched your search

+19 -5
View File
@@ -6,7 +6,8 @@ import {
WAYPOINT_ICON,
TRACK_ICON,
ROUTE_ICON,
GEOJSON_ICON,
PENDING_ICON,
DOWNLOAD_ICON,
MAP_MARKER_ICON,
POI_ICONS,
PARK4NIGHT_TAGS,
@@ -290,9 +291,10 @@ export class GpxPanelControl {
name.title = `Download ${displayName}`;
label.appendChild(checkbox);
(file.kinds || []).forEach((kind) => label.appendChild(this._kindIcon(kind)));
if (file.cached) label.appendChild(this._cachedIcon());
if (!file.cached) label.appendChild(this._pendingIcon());
label.appendChild(name);
row.appendChild(label);
row.appendChild(this._downloadButton(file));
row.appendChild(this._deleteButton(() => this._deleteFile(file.path)));
return row;
@@ -314,14 +316,26 @@ export class GpxPanelControl {
return icon;
}
_cachedIcon() {
_pendingIcon() {
const icon = document.createElement("span");
icon.className = "gpx-tree__kind-icon";
icon.innerHTML = GEOJSON_ICON;
icon.title = "Ready to view instantly (GeoJSON cached)";
icon.innerHTML = PENDING_ICON;
icon.title = "Not yet converted — dropped straight into data/gpx/, not uploaded through the app";
return icon;
}
// Same destination as clicking the file's name (gpxFileUrl + ?download=1)
// — a second, more obviously clickable entry point for the same action.
_downloadButton(file) {
const link = document.createElement("a");
link.className = "gpx-tree__download";
link.href = `${gpxFileUrl(file.path)}?download=1`;
link.title = "Download GeoJSON";
link.setAttribute("aria-label", "Download GeoJSON");
link.innerHTML = DOWNLOAD_ICON;
return link;
}
_deleteButton(onClick) {
const button = document.createElement("button");
button.type = "button";
+19 -7
View File
@@ -54,14 +54,26 @@ export const WAYPOINT_ICON = `
export const TRACK_ICON = GPX_ICON;
// Shown next to a file whose GeoJSON conversion is already cached on disk
// (GpxStore#geojson) — ready to view instantly instead of paying REXML's
// parse cost on click. Curly braces read as "structured data ready", the
// same shorthand most editors/tools use for JSON.
export const GEOJSON_ICON = `
// Shown next to a file whose GeoJSON conversion is NOT yet cached on disk
// (GpxStore#geojson) — the uncommon case, since GpxStore#save converts
// eagerly at upload time; this only happens for a .gpx/.fit dropped
// straight into data/gpx/ on the filesystem, bypassing the app, and not
// yet opened. Everything uploaded normally is cached almost immediately,
// so badging the common case would just be noise — this badges the
// exception instead.
export const PENDING_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 4c-1.5 0-2 .8-2 2v3c0 1-.5 1.5-1.5 1.5 1 0 1.5.5 1.5 1.5v3c0 1.2.5 2 2 2"/>
<path d="M15 4c1.5 0 2 .8 2 2v3c0 1 .5 1.5 1.5 1.5-1 0-1.5.5-1.5 1.5v3c0 1.2-.5 2-2 2"/>
<circle cx="12" cy="12" r="8"/>
<path d="M12 8v4l3 2"/>
</svg>`;
// A small download button next to each tree file's delete button — the
// name link (see gpx.js's _renderFile) does the same thing, but isn't
// obviously clickable at a glance, so this is the discoverable version.
export const DOWNLOAD_ICON = `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 4v11M8 11l4 4 4-4"/>
<path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/>
</svg>`;
// Same shape as TRACK_ICON, dashed — a route is planned rather than