diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-23 08:59:35 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-23 08:59:35 +0000 |
| commit | 23c670442392af1c75b935b3296ae2fc4fd094ba (patch) | |
| tree | 3137ff26aa5ed14ff8acb77007d4bc6ec2fff217 /internal/handlers/handlers.go | |
| parent | 92c784dd057d8f110c677516909162c4cd4d00da (diff) | |
fix: support multiple enabled Google Task lists and Calendars
- Update Google API interfaces with setters for list/calendar IDs
- Update fetchCalendarEvents and fetchGoogleTasks to use enabled IDs from source_configs
- Update timeline logic tests to reflect interface changes and seed config data
- Ensure dashboard respects user-selected lists from settings
Diffstat (limited to 'internal/handlers/handlers.go')
| -rw-r--r-- | internal/handlers/handlers.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 8abd4d7..fa97be0 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -373,6 +373,24 @@ func (h *Handler) fetchCalendarEvents(ctx context.Context, forceRefresh bool) ([ if h.googleCalendarClient == nil { return nil, nil } + + // Get enabled calendars from store + configs, _ := h.store.GetSourceConfigsBySource("gcal") + var enabledIDs []string + for _, cfg := range configs { + if cfg.Enabled { + enabledIDs = append(enabledIDs, cfg.ItemID) + } + } + + // 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 + } + + h.googleCalendarClient.SetCalendarIDs(enabledIDs) + fetcher := &CacheFetcher[models.CalendarEvent]{ Store: h.store, CacheKey: store.CacheKeyGoogleCalendar, @@ -389,6 +407,22 @@ func (h *Handler) fetchGoogleTasks(ctx context.Context, forceRefresh bool) ([]mo if h.googleTasksClient == nil { return nil, nil } + + // Get enabled task lists from store + configs, _ := h.store.GetSourceConfigsBySource("gtasks") + var enabledIDs []string + for _, cfg := range configs { + if cfg.Enabled { + enabledIDs = append(enabledIDs, cfg.ItemID) + } + } + + if len(enabledIDs) == 0 { + return nil, nil + } + + h.googleTasksClient.SetTaskListID(strings.Join(enabledIDs, ",")) + fetcher := &CacheFetcher[models.GoogleTask]{ Store: h.store, CacheKey: store.CacheKeyGoogleTasks, |
