From 52675c20363a4e9f91f071db14d6a01c762778ad Mon Sep 17 00:00:00 2001 From: Brittany Ellich Date: Mon, 1 Jun 2026 08:19:44 -0700 Subject: [PATCH] refactor(connections): View badge uses most-recent connection record Align the "connected at" / event badge with the current-event checkbox, which both now select the most-recent record via FindForTarget. Previously the badge used first-match-in-listRecords-order, which could disagree when a target had multiple connection records. Co-Authored-By: Claude Opus 4.8 --- features/connections/handlers.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/features/connections/handlers.go b/features/connections/handlers.go index 1fdb0b1..f29966c 100644 --- a/features/connections/handlers.go +++ b/features/connections/handlers.go @@ -424,15 +424,15 @@ func (h *Handlers) View(w http.ResponseWriter, r *http.Request) { if err != nil { slog.Debug("connections/view: list viewer connections", "err", err) } - for _, e := range entries { - if e.With == target { - view.ConnectedAt = e.ConnectedAt.Format("Jan 2, 2006") - if e.EventURI != "" { - if ev, err := event.Get(r.Context(), h.DB, e.EventURI); err == nil { - view.EventName = ev.Name - } + // Use the most-recent record for this target so the "connected at" / event + // badge agrees with the current-event checkbox below (which also targets + // the most-recent record). + if e, found := connection.FindForTarget(entries, target); found { + view.ConnectedAt = e.ConnectedAt.Format("Jan 2, 2006") + if e.EventURI != "" { + if ev, err := event.Get(r.Context(), h.DB, e.EventURI); err == nil { + view.EventName = ev.Name } - break } } -- 2.51.2