mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 21:31:46 +00:00
add mapbox gl option, gps location, journey reorder + polish
- Mapbox GL provider alongside Leaflet for trip and journey maps (opt-in in settings with token, style presets incl. 3D on satellite, quality mode, experimental badge). - GPS "blue dot" with heading cone on mobile; three-state FAB (off / show / follow), geodesic accuracy circle, desktop-hidden since browser IP geo is too coarse for navigation. - Marker drift fix: outer wrap no longer carries inline position/transform, so mapbox's translate keeps the pin pinned at every zoom and pitch. - Journey map popup (mapbox-gl): Apple-Maps-style tooltip on marker highlight/click showing entry title + location / date subline. - Journey feed reorder: up/down controls to the left of each entry reorder sort_order within a day. Server endpoint, optimistic store update, rollback on failure. - Journey entry editor: desktop modal now centers over the feed column only, backdrop still blurs the whole page (map included). - Scroll-sync guard on journey: marker click locks the sync so smooth-scroll can't steer the highlight to a neighbouring entry mid-animation. - Misc: map top-padding aligned with hero, live/synced badges replaced by a compact back-button in the hero, skeleton entries no longer pollute the journey map, journey detail no longer shows map on mobile path when combined view is active.
This commit is contained in:
@@ -598,6 +598,31 @@ export function updateEntry(entryId: number, userId: number, data: Partial<{
|
||||
return updated;
|
||||
}
|
||||
|
||||
// Reorder entries (typically within a single day). Caller passes the new
|
||||
// desired order of ids; each entry's sort_order is set to its index in the
|
||||
// array. Only entries owned by this journey are accepted.
|
||||
export function reorderEntries(journeyId: number, userId: number, orderedIds: number[], sid?: string): boolean {
|
||||
if (!canEdit(journeyId, userId)) return false;
|
||||
if (!orderedIds.length) return true;
|
||||
|
||||
const placeholders = orderedIds.map(() => '?').join(',');
|
||||
const rows = db
|
||||
.prepare(`SELECT id FROM journey_entries WHERE id IN (${placeholders}) AND journey_id = ?`)
|
||||
.all(...orderedIds, journeyId) as { id: number }[];
|
||||
if (rows.length !== orderedIds.length) return false;
|
||||
|
||||
const now = ts();
|
||||
const update = db.prepare('UPDATE journey_entries SET sort_order = ?, updated_at = ? WHERE id = ?');
|
||||
const tx = db.transaction(() => {
|
||||
orderedIds.forEach((id, index) => update.run(index, now, id));
|
||||
db.prepare('UPDATE journeys SET updated_at = ? WHERE id = ?').run(now, journeyId);
|
||||
});
|
||||
tx();
|
||||
|
||||
broadcastJourneyEvent(journeyId, 'journey:entries:reordered', { orderedIds }, sid);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function deleteEntry(entryId: number, userId: number, sid?: string): boolean {
|
||||
const entry = db.prepare('SELECT * FROM journey_entries WHERE id = ?').get(entryId) as JourneyEntry | undefined;
|
||||
if (!entry) return false;
|
||||
|
||||
Reference in New Issue
Block a user