diff options
Diffstat (limited to 'internal/handlers')
| -rw-r--r-- | internal/handlers/handlers.go | 10 | ||||
| -rw-r--r-- | internal/handlers/timeline.go | 7 |
2 files changed, 14 insertions, 3 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 5ecaf7c..eaef558 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -392,10 +392,14 @@ func (h *Handler) fetchCalendarEvents(ctx context.Context, forceRefresh bool) ([ } } - // If none enabled but we have a default from config, use that as a fallback - // (or if we want to respect the toggle strictly, we should only use enabled ones) if len(enabledIDs) == 0 { - return nil, nil + // No source_configs synced yet — fall back to the configured calendar ID + if len(configs) == 0 && h.config.GoogleCalendarID != "" { + enabledIDs = []string{h.config.GoogleCalendarID} + } else { + // Configs exist but all disabled — respect that + return nil, nil + } } h.googleCalendarClient.SetCalendarIDs(enabledIDs) diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go index bbdae51..2c3c6b6 100644 --- a/internal/handlers/timeline.go +++ b/internal/handlers/timeline.go @@ -69,6 +69,13 @@ func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) { log.Printf("Warning: failed to fetch calendar events: %v", err) } + // Refresh meals cache before building timeline + if h.planToEatClient != nil { + if _, err := h.fetchMeals(r.Context(), false); err != nil { + log.Printf("Warning: failed to fetch meals: %v", err) + } + } + // Call BuildTimeline items, err := BuildTimeline(r.Context(), h.store, start, end) if err != nil { |
