From 0b2c1c22c6e4169d42f469a9d004b71acc30e320 Mon Sep 17 00:00:00 2001 From: elpatron Date: Sun, 31 May 2026 21:29:42 +0200 Subject: [PATCH] Guard optional event fields before calling trim in live-log paths. Legacy decrypted events may omit mgk or wind fields; optional chaining prevents runtime crashes in course prefill and stats aggregation. Co-authored-by: Cursor --- client/src/components/LiveLogView.tsx | 6 ++++-- client/src/services/eventSeriesAggregation.ts | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/src/components/LiveLogView.tsx b/client/src/components/LiveLogView.tsx index c87e236..ab8638c 100644 --- a/client/src/components/LiveLogView.tsx +++ b/client/src/components/LiveLogView.tsx @@ -81,14 +81,16 @@ function hapticPulse() { function lastCourseFromEvents(events: LogEventPayload[]): string { for (let i = events.length - 1; i >= 0; i--) { - if (events[i].mgk.trim()) return events[i].mgk + const mgk = events[i].mgk?.trim() + if (mgk) return mgk } return '' } function lastWindDirectionFromEvents(events: LogEventPayload[]): string { for (let i = events.length - 1; i >= 0; i--) { - if (events[i].windDirection.trim()) return events[i].windDirection + const direction = events[i].windDirection?.trim() + if (direction) return direction } return '' } diff --git a/client/src/services/eventSeriesAggregation.ts b/client/src/services/eventSeriesAggregation.ts index 98bb2c2..5d980ff 100644 --- a/client/src/services/eventSeriesAggregation.ts +++ b/client/src/services/eventSeriesAggregation.ts @@ -71,21 +71,21 @@ export async function loadLogbookEventSeries(logbookId: string): Promise