summaryrefslogtreecommitdiff
path: root/internal/handlers/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/handlers.go')
-rw-r--r--internal/handlers/handlers.go34
1 files changed, 8 insertions, 26 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go
index 7220474..aedbd11 100644
--- a/internal/handlers/handlers.go
+++ b/internal/handlers/handlers.go
@@ -667,6 +667,8 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl
switch source {
case "trello":
_ = h.store.DeleteCard(id)
+ case "gtasks":
+ _ = h.store.InvalidateCache(store.CacheKeyGoogleTasks)
case "doot":
// native tasks stay in DB marked completed; no cache to invalidate
}
@@ -712,7 +714,9 @@ func (h *Handler) getAtomDetails(id, source string) (string, *time.Time) {
}
}
case "gtasks":
- return "Google Task", nil
+ if t, ok := h.findGoogleTask(id); ok {
+ return t.Title, t.DueDate
+ }
}
return "Task", nil
}
@@ -906,30 +910,8 @@ func (h *Handler) HandleTaskDetailPage(w http.ResponseWriter, r *http.Request) {
return
}
- var title, description string
- switch source {
- case "doot":
- if tasks, err := h.store.GetNativeTasks(); err == nil {
- for _, t := range tasks {
- if t.ID == id {
- title, description = t.Content, t.Description
- break
- }
- }
- }
- case "trello":
- if boards, err := h.store.GetBoards(); err == nil {
- for _, b := range boards {
- for _, c := range b.Cards {
- if c.ID == id {
- title, description = c.Name, c.Description
- break
- }
- }
- }
- }
- }
-
+ detail := h.loadTaskDetailData(id, source)
+ title := detail.Title
if title == "" {
title = "Task"
}
@@ -941,7 +923,7 @@ func (h *Handler) HandleTaskDetailPage(w http.ResponseWriter, r *http.Request) {
Description string
CSRFToken string
Saved bool
- }{title, id, source, description, auth.GetCSRFTokenFromContext(r.Context()), r.URL.Query().Get("saved") == "1"}
+ }{title, id, source, detail.Description, auth.GetCSRFTokenFromContext(r.Context()), r.URL.Query().Get("saved") == "1"}
if err := h.renderer.Render(w, "task-detail-page.html", data); err != nil {
http.Error(w, "Failed to render template", http.StatusInternalServerError)