Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/eca/features/tools/task.clj
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,14 @@
"Clear the task list when all tasks are done.
Returns task-details of the cleared state if clearing occurred, nil otherwise."
[db* chat-id]
(when (all-tasks-done? (get-task @db* chat-id))
(mutate-task! db* chat-id (fn [_] {:state empty-task}))
(task-details empty-task)))
(loop []
(let [db @db*
state (get-task db chat-id)]
(when (all-tasks-done? state)
(let [new-db (assoc-in db [:chats chat-id :task] empty-task)]
(if (compare-and-set! db* db new-db)
(task-details empty-task)
(recur)))))))

;; --- Operations ---

Expand Down
Loading