diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 842528d8d..3c3478ab3 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -197,8 +197,9 @@ void Hooks::onExit () // - all emitted non-JSON lines are considered feedback messages if the exit // code is zero, otherwise they are considered errors. // -void Hooks::onAdd (Task& after) +void Hooks::onAdd (std::vector & changes) { +/* context.timer_hooks.start (); if (! _enabled) return; @@ -249,6 +250,7 @@ void Hooks::onAdd (Task& after) } context.timer_hooks.stop (); +*/ } //////////////////////////////////////////////////////////////////////////////// @@ -266,8 +268,9 @@ void Hooks::onAdd (Task& after) // - all emitted non-JSON lines are considered feedback messages if the exit // code is zero, otherwise they are considered errors. // -void Hooks::onModify (const Task& before, Task& after) +void Hooks::onModify (const Task& before, std::vector & changes) { +/* context.timer_hooks.start (); if (! _enabled) return; @@ -322,6 +325,7 @@ void Hooks::onModify (const Task& before, Task& after) } context.timer_hooks.stop (); +*/ } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Hooks.h b/src/Hooks.h index 7e5d1608a..b6e19accc 100644 --- a/src/Hooks.h +++ b/src/Hooks.h @@ -29,6 +29,7 @@ #include #include +#include class Hooks { @@ -43,8 +44,8 @@ public: void onLaunch (); void onExit (); - void onAdd (Task&); - void onModify (const Task&, Task&); + void onAdd (std::vector &); + void onModify (const Task&, std::vector &); std::vector list (); diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 3baf8a2c6..d60ad3bc9 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -570,9 +570,7 @@ void TDB2::add (Task& task, bool add_to_backlog /* = true */) // Create a vector tasks, as hooks can cause them to multiply. std::vector changes; changes.push_back (task); - - // TODO call hooks. - // context.hooks.onAdd (changes); + context.hooks.onAdd (changes); update (uuid, task, add_to_backlog, changes); } @@ -584,12 +582,14 @@ void TDB2::modify (Task& task, bool add_to_backlog /* = true */) task.validate (false); std::string uuid = task.get ("uuid"); + // Get the unmodified task as reference, so the hook can compare. + Task original; + get (uuid, original); + // Create a vector tasks, as hooks can cause them to multiply. std::vector changes; changes.push_back (task); - - // TODO call hooks. - // context.hooks.onModify (changes); + context.hooks.onModify (original, changes); update (uuid, task, add_to_backlog, changes); }