feat(gamification): emit task-uncompleted + task-deleted events
Phase 8 completionStats store listens on these events to refresh the daily count. Keeps the badge + sparkline accurate after un-tick / delete paths, which don't currently fire kon:task-completed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -445,6 +445,9 @@ export async function deleteTask(id: string) {
|
|||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
tasks.splice(idx, 1);
|
tasks.splice(idx, 1);
|
||||||
broadcastTasks();
|
broadcastTasks();
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
window.dispatchEvent(new CustomEvent("kon:task-deleted", { detail: { id } }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toasts.error("Couldn't delete task", errorMessage(err));
|
toasts.error("Couldn't delete task", errorMessage(err));
|
||||||
@@ -474,6 +477,9 @@ export async function uncompleteTask(id: string) {
|
|||||||
try {
|
try {
|
||||||
await invoke("uncomplete_task_cmd", { id });
|
await invoke("uncomplete_task_cmd", { id });
|
||||||
applyLocalTaskUpdate(id, { done: false, doneAt: null });
|
applyLocalTaskUpdate(id, { done: false, doneAt: null });
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
window.dispatchEvent(new CustomEvent("kon:task-uncompleted", { detail: { id } }));
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toasts.error("Couldn't uncomplete task", errorMessage(err));
|
toasts.error("Couldn't uncomplete task", errorMessage(err));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user