From b2d8fc460be3105ac383098e7cdc92171e5026ec Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 23 Mar 2026 08:13:02 +0000 Subject: feat: unify Google Tasks with main system via caching and integrated UI - Implement SQLite caching layer for Google Tasks - Integrate Google Tasks into unified Atoms loop (showing in Tasks tab) - Update Planning tab to include cached Google Tasks - Enhance Quick Add form with Todoist project selector - Remove orphaned HandleTasksTab/HandleRefreshTab methods - Update tests to reflect new BuildTimeline signature and data structures --- internal/handlers/timeline_logic.go | 56 +++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'internal/handlers/timeline_logic.go') diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go index 145e851..8430ee9 100644 --- a/internal/handlers/timeline_logic.go +++ b/internal/handlers/timeline_logic.go @@ -7,14 +7,13 @@ import ( "strings" "time" - "task-dashboard/internal/api" "task-dashboard/internal/config" "task-dashboard/internal/models" "task-dashboard/internal/store" ) // BuildTimeline aggregates and normalizes data into a timeline structure -func BuildTimeline(ctx context.Context, s *store.Store, tasksClient api.GoogleTasksAPI, start, end time.Time) ([]models.TimelineItem, error) { +func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([]models.TimelineItem, error) { var items []models.TimelineItem now := config.Now() @@ -145,37 +144,32 @@ func BuildTimeline(ctx context.Context, s *store.Store, tasksClient api.GoogleTa } } - // 5. Fetch Google Tasks - if tasksClient != nil { - gTasks, err := tasksClient.GetTasksByDateRange(ctx, start, end) - if err != nil { - log.Printf("Warning: failed to fetch Google Tasks: %v", err) - } else { - log.Printf("Google Tasks: fetched %d tasks in date range", len(gTasks)) - for _, gTask := range gTasks { - // Tasks without due date are placed in today section - taskTime := now - if gTask.DueDate != nil { - taskTime = *gTask.DueDate - } - item := models.TimelineItem{ - ID: gTask.ID, - Type: models.TimelineItemTypeGTask, - Title: gTask.Title, - Time: taskTime, - Description: gTask.Notes, - URL: gTask.URL, - OriginalItem: gTask, - IsCompleted: gTask.Completed, - Source: "gtasks", - ListID: gTask.ListID, - } - item.ComputeDaySection(now) - items = append(items, item) + // 5. Fetch Google Tasks from store cache + gTasks, err := s.GetGoogleTasksByDateRange(start, end) + if err != nil { + log.Printf("Warning: failed to read cached Google Tasks: %v", err) + } else { + for _, gTask := range gTasks { + // Tasks without due date are placed in today section + taskTime := now + if gTask.DueDate != nil { + taskTime = *gTask.DueDate + } + item := models.TimelineItem{ + ID: gTask.ID, + Type: models.TimelineItemTypeGTask, + Title: gTask.Title, + Time: taskTime, + Description: gTask.Notes, + URL: gTask.URL, + OriginalItem: gTask, + IsCompleted: gTask.Completed, + Source: "gtasks", + ListID: gTask.ListID, } + item.ComputeDaySection(now) + items = append(items, item) } - } else { - log.Printf("Google Tasks client not configured") } // Sort items by Time -- cgit v1.2.3