From b5aa7c6ae24944f7d5ccee25715b20d024aab6b5 Mon Sep 17 00:00:00 2001 From: Felix Schurk <75752337+felixschurk@users.noreply.github.com> Date: Sat, 6 Apr 2024 02:45:55 +0300 Subject: [PATCH] change order of hook invocation and setting task id (#3339) this prevents that the task id is always returned as zero after a hook is run on it closes #3312 --- src/TDB2.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index b729c9a63..91fc3a61a 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -87,7 +87,7 @@ void TDB2::add (Task& task) for (auto& attr : task.all ()) { // TaskChampion does not store uuid or id in the taskmap if (attr == "uuid" || attr == "id") { - continue; + continue; } // Use `set_status` for the task status, to get expected behavior @@ -118,12 +118,13 @@ void TDB2::add (Task& task) // update the cached working set with the new information _working_set = std::make_optional (std::move (ws)); - if (id.has_value ()) { - task.id = id.value(); - } - // run hooks for this new task Context::getContext ().hooks.onAdd (task); + + if (id.has_value ()) { + task.id = id.value(); + } + } ////////////////////////////////////////////////////////////////////////////////