mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
feat(journey): make the linked trips' GPX tracks a switch, off by default
#1260 drew the GPX tracks of every trip behind a journey onto its map, with nothing to switch off — the reasoning being that a route imported into a linked trip is part of the journey's story. For a trip carrying a season of recorded drives it is instead a map nobody asked for, drawn from places that never became an entry. So it becomes a journey-level setting, owner-only like the other Journey Settings, and it starts off: a journal should show what its author put in it, and #1260's set is everything the linked trips happen to contain. The switch gates the request, not just the rendering — the endpoint ships full unthinned geometry, which is megabytes fetched on every journey open for a map nobody wanted. `journeyTracks()` itself is deliberately untouched, so TREK Studio keeps the set its saved books were laid out with. Also fixes what the reporter's screenshot actually shows: JourneyMap fed track coordinates into `fitBounds`, so one drive across a country zoomed the journey map out until the entries were specks. Tracks now only frame the map when there is nothing else to frame, which is what JourneyMapGL already did — the same journey used to open at two different zooms depending on the renderer. Closes #2194 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S5VwmiBQ9sPCJwfmpv64r3
This commit is contained in:
@@ -4191,6 +4191,29 @@ function runMigrations(db: Database.Database): void {
|
||||
() => {
|
||||
db.prepare("UPDATE addons SET type = 'integration' WHERE id = 'naver_list_import'").run();
|
||||
},
|
||||
/**
|
||||
* Whether a journey's map draws the GPX tracks of the trips behind it (#2194).
|
||||
*
|
||||
* #1260 added those tracks unconditionally and with nothing to switch off,
|
||||
* on the reasoning that a route imported into a linked trip is part of the
|
||||
* journey's story. For a trip carrying a season of recorded drives it is
|
||||
* instead a map nobody asked for, drawn from places that never became an
|
||||
* entry — so it becomes a journey-level setting.
|
||||
*
|
||||
* DEFAULT 0, i.e. off: the tracks are opt-in from here on. That is a
|
||||
* deliberate behaviour change rather than a preserved default — a journal
|
||||
* should show what its author put in it, and #1260's set is everything the
|
||||
* linked trips happen to contain. Owners who want them back have one
|
||||
* switch in Journey Settings.
|
||||
*
|
||||
* Appended LAST: the array is index-addressed against schema_version.
|
||||
*/
|
||||
() => {
|
||||
const cols = db.prepare("SELECT name FROM pragma_table_info('journeys')").all() as Array<{ name: string }>;
|
||||
if (!cols.some(c => c.name === 'show_trip_tracks')) {
|
||||
db.exec('ALTER TABLE journeys ADD COLUMN show_trip_tracks INTEGER NOT NULL DEFAULT 0');
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
if (currentVersion < migrations.length) {
|
||||
|
||||
@@ -329,6 +329,7 @@ export class JourneyDomainService {
|
||||
cover_gradient: string;
|
||||
cover_image: string;
|
||||
status: string;
|
||||
show_trip_tracks: boolean | number;
|
||||
}>,
|
||||
): Journey | null {
|
||||
// Journey-level settings (title, cover, status) are owner-only — editors
|
||||
@@ -336,14 +337,17 @@ export class JourneyDomainService {
|
||||
if (!this.isOwner(journeyId, userId)) return null;
|
||||
|
||||
const ALLOWED_STATUSES = ['draft', 'active', 'completed', 'archived'];
|
||||
const allowed = ['title', 'subtitle', 'cover_gradient', 'cover_image', 'status'];
|
||||
const allowed = ['title', 'subtitle', 'cover_gradient', 'cover_image', 'status', 'show_trip_tracks'];
|
||||
// Stored as INTEGER, and better-sqlite3 refuses to bind a JS boolean, so the
|
||||
// one flag on this table is coerced rather than passed through.
|
||||
const BOOLEAN_FIELDS = new Set(['show_trip_tracks']);
|
||||
const fields: string[] = [];
|
||||
const values: unknown[] = [];
|
||||
for (const [key, val] of Object.entries(data)) {
|
||||
if (val !== undefined && allowed.includes(key)) {
|
||||
if (key === 'status' && !ALLOWED_STATUSES.includes(val as string)) continue;
|
||||
fields.push(`${key} = ?`);
|
||||
values.push(val);
|
||||
values.push(BOOLEAN_FIELDS.has(key) ? (val ? 1 : 0) : val);
|
||||
}
|
||||
}
|
||||
if (fields.length === 0) return this.db.prepare('SELECT * FROM journeys WHERE id = ?').get(journeyId) as Journey;
|
||||
|
||||
@@ -356,6 +356,8 @@ export interface Journey {
|
||||
cover_gradient?: string | null;
|
||||
cover_image?: string | null;
|
||||
status: 'draft' | 'active' | 'completed' | 'archived';
|
||||
/** Draw the linked trips' GPX tracks on this journey's map (#2194). 0 by default. */
|
||||
show_trip_tracks?: number;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user