From 187207957108f6be3c0e0b1551decbe9eaa5b3e9 Mon Sep 17 00:00:00 2001 From: bboysoul Date: Tue, 8 Sep 2026 17:25:14 +0800 Subject: [PATCH] fix: refresh tasks after completion --- frontend/src/App.vue | 6 +++++- frontend/src/style.test.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 53a9359..49d0e16 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -499,7 +499,11 @@ async function patchTask(task: Task, patch: Partial) { async function toggle(task: Task) { try { await patchTask(task, { completed: !task.completed }) - if (activeView.value === 'today') void loadTodayTaskSummary() + await loadTasksPage() + if (activeView.value === 'today') { + await loadOverdueTasks() + void loadTodayTaskSummary() + } toast(task.completed ? '已重新打开' : '完成啦') } catch (reason) { fail(reason) } } diff --git a/frontend/src/style.test.ts b/frontend/src/style.test.ts index 46049f1..7dcd733 100644 --- a/frontend/src/style.test.ts +++ b/frontend/src/style.test.ts @@ -101,6 +101,15 @@ describe('task and habit row decoration', () => { expect(css).toContain('.task-check:focus-visible{') }) + it('refreshes the current task data after toggling completion', () => { + const toggleBlock = app.slice(app.indexOf('async function toggle(task: Task)'), app.indexOf('function isInteractiveTarget')) + expect(toggleBlock).toContain('await patchTask(task, { completed: !task.completed })') + expect(toggleBlock).toContain('await loadTasksPage()') + expect(toggleBlock).toContain("if (activeView.value === 'today')") + expect(toggleBlock).toContain('await loadOverdueTasks()') + expect(toggleBlock).toContain('void loadTodayTaskSummary()') + }) + it('shows the same visible round check control for boolean and numeric habits in both views', () => { expect(mvpPanel).not.toContain('class="sr-only" :aria-label="isDone(h, todayKey)') expect(mvpPanel.match(/class="task-check habit-check"/g)?.length).toBe(2)