diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/handlers/handlers.go | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 19d26be..0903cf3 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -814,6 +814,58 @@ func (h *Handler) HandleGetTaskDetail(w http.ResponseWriter, r *http.Request) { }{title, id, source, description}) } +// HandleTaskDetailPage renders a standalone full-page task detail view (used by Android widget deep-links). +func (h *Handler) HandleTaskDetailPage(w http.ResponseWriter, r *http.Request) { + id := r.URL.Query().Get("id") + source := r.URL.Query().Get("source") + + if id == "" || source == "" { + http.Error(w, "Missing id or source", http.StatusBadRequest) + return + } + + var title, description string + switch source { + case "todoist": + if tasks, err := h.store.GetTasks(); 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 = c.Name + break + } + } + } + } + } + + if title == "" { + title = "Task" + } + + data := struct { + Title string + ID string + Source string + Description string + CSRFToken string + Saved bool + }{title, id, source, 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) + } +} + // HandleUpdateTask updates a task description func (h *Handler) HandleUpdateTask(w http.ResponseWriter, r *http.Request) { if err := r.ParseForm(); err != nil { @@ -846,7 +898,11 @@ func (h *Handler) HandleUpdateTask(w http.ResponseWriter, r *http.Request) { return } - w.WriteHeader(http.StatusOK) + if r.Header.Get("HX-Request") != "" { + w.WriteHeader(http.StatusOK) + } else { + http.Redirect(w, r, "/task?id="+id+"&source="+source+"&saved=1", http.StatusSeeOther) + } } // HandleTabTasks renders the unified Tasks tab (Todoist + Trello cards with due dates + Bugs + Google Tasks) |
