fix(rcal): show calendar event locations on map in all spaces, not just demo

REST API events use location_lat/location_lng while the map panel
filters on latitude/longitude. Demo events set both, but non-demo
events only had location_lat/location_lng — so the map was always
empty outside demo.

Normalize both REST and Automerge event data to include latitude/
longitude aliases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-25 17:10:44 -07:00
parent aa02473d0d
commit ba56697e23
2 changed files with 11 additions and 2 deletions

View File

@ -261,6 +261,8 @@ class FolkCalendarView extends HTMLElement {
source_name: e.sourceName, source_color: e.sourceColor,
location_name: e.locationName,
location_lat: e.locationLat, location_lng: e.locationLng,
latitude: e.locationLat ?? null,
longitude: e.locationLng ?? null,
}));
// Only use doc events if REST hasn't loaded yet
if (this.events.length === 0 && docEvents.length > 0) {
@ -692,7 +694,14 @@ class FolkCalendarView extends HTMLElement {
fetch(`${base}/api/lunar?start=${start}&end=${end}`),
fetch(`${schedBase}/api/reminders?upcoming=true`).catch(() => null),
]);
if (eventsRes.ok) { const data = await eventsRes.json(); this.events = data.results || []; }
if (eventsRes.ok) {
const data = await eventsRes.json();
this.events = (data.results || []).map((e: any) => ({
...e,
latitude: e.latitude ?? e.location_lat ?? null,
longitude: e.longitude ?? e.location_lng ?? null,
}));
}
if (sourcesRes.ok) { const data = await sourcesRes.json(); this.sources = data.results || []; }
if (lunarRes.ok) { this.lunarData = await lunarRes.json(); }
if (remindersRes?.ok) { const data = await remindersRes.json(); this.reminders = data.reminders || []; }

View File

@ -985,7 +985,7 @@ routes.get("/", (c) => {
modules: getModuleInfoList(),
theme: "dark",
body: `<folk-calendar-view space="${space}"></folk-calendar-view>`,
scripts: `<script type="module" src="/modules/rcal/folk-calendar-view.js?v=3"></script>`,
scripts: `<script type="module" src="/modules/rcal/folk-calendar-view.js?v=4"></script>`,
styles: `<link rel="stylesheet" href="/modules/rcal/cal.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" crossorigin="">`,
}));