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 } }