fix: refresh tasks after completion
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 4m1s

This commit is contained in:
2026-09-08 17:25:14 +08:00
parent ab46bb4f6a
commit 1872079571
2 changed files with 14 additions and 1 deletions
+5 -1
View File
@@ -499,7 +499,11 @@ async function patchTask(task: Task, patch: Partial<Task>) {
async function toggle(task: Task) { async function toggle(task: Task) {
try { try {
await patchTask(task, { completed: !task.completed }) 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 ? '已重新打开' : '完成啦') toast(task.completed ? '已重新打开' : '完成啦')
} catch (reason) { fail(reason) } } catch (reason) { fail(reason) }
} }
+9
View File
@@ -101,6 +101,15 @@ describe('task and habit row decoration', () => {
expect(css).toContain('.task-check:focus-visible{') 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', () => { 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).not.toContain('class="sr-only" :aria-label="isDone(h, todayKey)')
expect(mvpPanel.match(/class="task-check habit-check"/g)?.length).toBe(2) expect(mvpPanel.match(/class="task-check habit-check"/g)?.length).toBe(2)