diff options
Diffstat (limited to 'internal/handlers/handlers.go')
| -rw-r--r-- | internal/handlers/handlers.go | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 9fe1b2c..0e5edcc 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -673,8 +673,11 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl } if complete { - // Get task title before removing from cache - title := h.getAtomTitle(id, source) + // Get task details before removing from cache + title, dueDate := h.getAtomDetails(id, source) + + // Log to completed tasks + _ = h.store.SaveCompletedTask(source, id, title, dueDate) // Remove from local cache switch source { @@ -706,14 +709,14 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl } } -// getAtomTitle retrieves the title for a task/card/bug from the store -func (h *Handler) getAtomTitle(id, source string) string { +// getAtomDetails retrieves title and due date for a task/card/bug from the store +func (h *Handler) getAtomDetails(id, source string) (string, *time.Time) { switch source { case "todoist": if tasks, err := h.store.GetTasks(); err == nil { for _, t := range tasks { if t.ID == id { - return t.Content + return t.Content, t.DueDate } } } @@ -722,7 +725,7 @@ func (h *Handler) getAtomTitle(id, source string) string { for _, b := range boards { for _, c := range b.Cards { if c.ID == id { - return c.Name + return c.Name, c.DueDate } } } @@ -733,13 +736,22 @@ func (h *Handler) getAtomTitle(id, source string) string { if _, err := fmt.Sscanf(id, "bug-%d", &bugID); err == nil { for _, b := range bugs { if b.ID == bugID { - return b.Description + return b.Description, nil } } } } + case "gtasks": + // Google Tasks don't have local cache, return generic title + return "Google Task", nil } - return "Task" + return "Task", nil +} + +// getAtomTitle retrieves the title for a task/card/bug from the store (legacy) +func (h *Handler) getAtomTitle(id, source string) string { + title, _ := h.getAtomDetails(id, source) + return title } // HandleUnifiedAdd creates a task in Todoist or a card in Trello from the Quick Add form |
