summaryrefslogtreecommitdiff
path: root/internal/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers')
-rw-r--r--internal/handlers/timeline_logic.go13
-rw-r--r--internal/handlers/widget.go4
2 files changed, 17 insertions, 0 deletions
diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go
index 6fddd1d..b90b61e 100644
--- a/internal/handlers/timeline_logic.go
+++ b/internal/handlers/timeline_logic.go
@@ -17,6 +17,16 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([
var items []models.TimelineItem
now := config.Now()
+ // Fetch all projects once into a color lookup map
+ projectColors := make(map[string]string)
+ if projects, err := s.GetProjects(); err != nil {
+ log.Printf("Warning: failed to read projects: %v", err)
+ } else {
+ for _, p := range projects {
+ projectColors[p.ID] = p.Color
+ }
+ }
+
// 1. Fetch Meals - combine multiple items for same date+mealType
meals, err := s.GetMealsByDateRange(start, end)
if err != nil {
@@ -147,6 +157,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([
OriginalItem: task,
IsCompleted: task.Completed,
Source: "doot",
+ ProjectColor: projectColors[task.ProjectID],
}
item.ComputeDaySection(now)
items = append(items, item)
@@ -170,6 +181,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([
OriginalItem: task,
IsCompleted: task.Completed,
Source: "doot",
+ ProjectColor: projectColors[task.ProjectID],
}
item.ComputeDaySection(now)
items = append(items, item)
@@ -191,6 +203,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([
IsCompleted: task.Completed,
Source: "doot",
IsAllDay: true,
+ ProjectColor: projectColors[task.ProjectID],
}
item.ComputeDaySection(now)
items = append(items, item)
diff --git a/internal/handlers/widget.go b/internal/handlers/widget.go
index 1bb706e..05c0bdb 100644
--- a/internal/handlers/widget.go
+++ b/internal/handlers/widget.go
@@ -97,6 +97,10 @@ func TimelineItemToWidgetItem(item models.TimelineItem) models.WidgetItem {
wi.DueDate = &due
}
+ if item.ProjectColor != "" {
+ wi.ProjectColor = &item.ProjectColor
+ }
+
return wi
}