summaryrefslogtreecommitdiff
path: root/internal/handlers/timeline_logic.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-06-29 08:53:48 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-06-29 08:53:48 +0000
commit3fbfdd1f9441299eb146bf215449f238977deb66 (patch)
treea01d0cd35309afbab6cc8989e26e2e824442c898 /internal/handlers/timeline_logic.go
parentde3e37cca4f34a30f9c0beef05f67c3d515d64c2 (diff)
feat: native task management + Todoist migration
Adds doot-owned task storage (native_tasks table) so tasks can be managed without Todoist. CompleteTask for 'doot' source just updates the DB — no external API call, no token dependency. Migration path: POST /settings/import-from-todoist — copies Todoist cache → native_tasks Then remove TODOIST_TOKEN from .env to disable Todoist Changes: - migration 020: native_tasks table - store: GetNativeTasks, GetNativeTasksByDateRange, GetUndatedNativeTasks, CreateNativeTask, CompleteNativeTask, UncompleteNativeTask, UpdateNativeTask, ImportFromTodoist - timeline: native tasks appear as source="doot" (teal) - handleAtomToggle: "doot" case — no external API needed - HandleWidgetComplete: method on Handler, handles "doot" natively - HandleUnifiedAdd: "doot" source creates in native_tasks - widget: "doot" tasks are completable, teal color indicator Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers/timeline_logic.go')
-rw-r--r--internal/handlers/timeline_logic.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go
index 8430ee9..c9510bf 100644
--- a/internal/handlers/timeline_logic.go
+++ b/internal/handlers/timeline_logic.go
@@ -172,6 +172,51 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([
}
}
+ // 6. Fetch native (doot-owned) tasks
+ nativeDated, err := s.GetNativeTasksByDateRange(start, end)
+ if err != nil {
+ log.Printf("Warning: failed to read native tasks: %v", err)
+ } else {
+ for _, task := range nativeDated {
+ if task.DueDate == nil {
+ continue
+ }
+ item := models.TimelineItem{
+ ID: task.ID,
+ Type: models.TimelineItemTypeTask,
+ Title: task.Content,
+ Time: *task.DueDate,
+ Description: task.Description,
+ OriginalItem: task,
+ IsCompleted: task.Completed,
+ Source: "doot",
+ }
+ item.ComputeDaySection(now)
+ items = append(items, item)
+ }
+ }
+
+ nativeUndated, err := s.GetUndatedNativeTasks()
+ if err != nil {
+ log.Printf("Warning: failed to read undated native tasks: %v", err)
+ } else {
+ for _, task := range nativeUndated {
+ item := models.TimelineItem{
+ ID: task.ID,
+ Type: models.TimelineItemTypeTask,
+ Title: task.Content,
+ Time: now,
+ Description: task.Description,
+ OriginalItem: task,
+ IsCompleted: task.Completed,
+ Source: "doot",
+ IsAllDay: true,
+ }
+ item.ComputeDaySection(now)
+ items = append(items, item)
+ }
+ }
+
// Sort items by Time
sort.Slice(items, func(i, j int) bool {
return items[i].Time.Before(items[j].Time)