aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-30 11:38:15 +0100
committerDanilo M. <danix@danix.xyz>2026-11-30 11:38:15 +0100
commit4d6f14e7d106dadeb354081a32dfa8b1f40371e0 (patch)
tree0c2c8c9aee5ccc3085b125462bb17684f472d309
parent30fed7fc778560e759ae5602901d898af80e0a28 (diff)
downloaddeck-it-4d6f14e7d106dadeb354081a32dfa8b1f40371e0.tar.gz
deck-it-4d6f14e7d106dadeb354081a32dfa8b1f40371e0.zip
fix(todo): open tasks at the configured URL, animate done and snoozeHEADmaster
Vikunja's frontend_url said port 80, so a tap opened the wrong page; the frontend lives at the API's address, so open uses [todo] url. A hold now turns the chip green with a ticked box and shrinks it away, a snooze carries it off to the right; the row is redrawn only after the animation, so it is not cut short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--deckit/modules/todo.py8
-rw-r--r--static/dashboard.js39
-rw-r--r--static/deck.css3
-rw-r--r--tests/test_todo.py4
4 files changed, 33 insertions, 21 deletions
diff --git a/deckit/modules/todo.py b/deckit/modules/todo.py
index 8ce673d..3c698e0 100644
--- a/deckit/modules/todo.py
+++ b/deckit/modules/todo.py
@@ -104,7 +104,6 @@ class Todo:
self.pass_ = cfg.get("pass", _pass)
self.token = None
self.now = cfg.get("now", lambda: datetime.now(timezone.utc))
- self.front = None
self.st = {"tasks": [], "error": None}
self.wake, self.stopping = threading.Event(), False
self.actions = {"open": self._open, "done": self._done, "snooze": self._snooze} if self.url else {}
@@ -123,8 +122,6 @@ class Todo:
def refresh(self):
try:
- if self.front is None:
- self.front = self.http("GET", self.url + "/api/v1/info", "").get("frontend_url", "")
items = self._call("GET", "/api/v2/tasks?" + urllib.parse.urlencode(
{"filter": FILTER, "per_page": 50})).get("items") or []
self.st = {"tasks": pick(items, self.now()), "error": None}
@@ -148,8 +145,9 @@ class Todo:
def _open(self, body):
i = self._id(body)
- base = (self.front or self.url).rstrip("/")
- self._write(lambda: self.popen(["xdg-open", f"{base}/tasks/{i}"]))
+ # ponytail: the frontend at the API's address; /api/v1/info's frontend_url
+ # is often wrong behind a port (it says :80). A [todo] frontend if they ever differ.
+ self._write(lambda: self.popen(["xdg-open", f"{self.url}/tasks/{i}"]))
def _done(self, body):
i = self._id(body)
diff --git a/static/dashboard.js b/static/dashboard.js
index 91ab2ec..072dbe1 100644
--- a/static/dashboard.js
+++ b/static/dashboard.js
@@ -27,7 +27,7 @@ const RUNNING = { k1c: "K1C", sbbuilder: "build", obs: "OBS" }; // the running
const G = { cpu: "", mem: "\u{f035b}", gpu: "\u{f08ae}", net: "\u{f04e1}",
wifi: "", charging: "\u{f0084}", tux: "", clock: "",
- todo: "\u{f0131}" };
+ todo: "\u{f0131}", done: "\u{f0135}" };
const BATTERY = ["", "", "", "", ""];
// Nerd Font distro logos by os-release ID.
const DISTRO = {
@@ -147,7 +147,7 @@ function gestures(el, { tap, hold, swipe }) {
el.addEventListener("pointerup", () => {
const wasTap = timer != null, wasSwipe = sliding && dx > el.offsetWidth / 3;
reset();
- if (wasSwipe) { el.style.transform = "translateX(110%)"; swipe(); }
+ if (wasSwipe) swipe();
else el.style.transform = "";
if (wasTap) tap();
});
@@ -330,15 +330,18 @@ export default {
todo.firstChild.title = st.error;
return;
}
- const act = async (name, id, line) => {
- let ok = false;
- try {
- ok = (await fetch(`/api/todo/${name}`, {
- method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id }) })).ok;
- if (ok && name !== "open") drawTodo(await (await fetch("/api/todo")).json());
- } catch {}
+ // exit: the chip's leaving animation; the row is redrawn once both it
+ // and the request are over, so the animation is never cut short.
+ const act = async (name, id, line, exit) => {
+ const post = fetch(`/api/todo/${name}`, {
+ method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id }) })
+ .then((r) => r.ok, () => false);
+ const [ok] = await Promise.all([post, exit?.finished.catch(() => {})]);
+ if (ok && exit) {
+ try { drawTodo(await (await fetch("/api/todo")).json()); } catch {}
+ }
if (!ok) { // back in place, red for a moment
- line.classList.remove("gone");
+ exit?.cancel();
line.style.transform = "";
line.classList.add("fail");
setTimeout(() => line.classList.remove("fail"), 1500);
@@ -354,8 +357,20 @@ export default {
line.querySelector(".due").textContent = due;
line.classList.toggle("late", due.startsWith("overdue"));
gestures(line, { tap: () => act("open", t.id, line),
- hold: () => { line.classList.add("gone"); act("done", t.id, line); },
- swipe: () => act("snooze", t.id, line) });
+ // done: a green check, then the chip shrinks away
+ hold: () => {
+ line.querySelector(".nf").textContent = G.done;
+ line.classList.add("done");
+ act("done", t.id, line, line.animate(
+ [{ opacity: 1, transform: "scale(1)", offset: 0.4 },
+ { opacity: 0, transform: "scale(0.6)" }],
+ { duration: 650, easing: "ease-in", fill: "forwards" }));
+ },
+ // snooze: the chip carries on to the right and fades
+ swipe: () => act("snooze", t.id, line, line.animate(
+ [{ transform: line.style.transform, opacity: 1 },
+ { transform: "translateX(120%)", opacity: 0 }],
+ { duration: 300, easing: "ease-out", fill: "forwards" })) });
todo.append(line);
}
if (tasks.length > 3) {
diff --git a/static/deck.css b/static/deck.css
index 04825a0..9731e25 100644
--- a/static/deck.css
+++ b/static/deck.css
@@ -758,7 +758,8 @@ select {
transition: transform .25s ease, opacity .25s ease, background-color .8s ease; }
.dash-todo .td.sliding { transition: none; }
.dash-todo .td.holding { background: color-mix(in srgb, var(--udt-green) 35%, var(--udt-surface0)); }
-.dash-todo .td.gone { opacity: 0; transform: scale(.97); }
+.dash-todo .td.done { background: color-mix(in srgb, var(--udt-green) 45%, var(--udt-surface0)); }
+.dash-todo .td.done .nf { color: var(--udt-green); }
.dash-todo .td.fail { background: color-mix(in srgb, var(--udt-red) 35%, var(--udt-surface0)); }
.dash-todo .td .nf { color: var(--udt-accent); font-size: 1.1rem; }
.dash-todo .td .col { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
diff --git a/tests/test_todo.py b/tests/test_todo.py
index 9307012..8834f7e 100644
--- a/tests/test_todo.py
+++ b/tests/test_todo.py
@@ -58,8 +58,6 @@ class Fake:
def __call__(self, method, url, token, data=None):
self.calls.append((method, url, data, token))
- if url.endswith("/api/v1/info"):
- return {"frontend_url": "http://vikunja.example.org/"}
if method == "GET" and "/api/v2/tasks?" in url:
return {"items": self.tasks}
if method == "GET":
@@ -108,7 +106,7 @@ class Module(unittest.TestCase):
def test_open_runs_xdg_open_on_the_task(self):
self.m.actions["open"]({"id": 7})
- self.assertEqual(self.opened, [["xdg-open", "http://vikunja.example.org/tasks/7"]])
+ self.assertEqual(self.opened, [["xdg-open", "http://vikunja.example.org:3456/tasks/7"]])
def test_done_patches_only_done(self):
self.m.actions["done"]({"id": 7})