Merge pull request #1139 from automatisch/update-flow-status-accordingly
fix: update flow.active when remote calls succeed
This commit is contained in:
@@ -25,14 +25,12 @@ const updateFlowStatus = async (
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
if (flow.active === params.input.active) {
|
||||
const newActiveValue = params.input.active;
|
||||
|
||||
if (flow.active === newActiveValue) {
|
||||
return flow;
|
||||
}
|
||||
|
||||
flow = await flow.$query().withGraphFetched('steps').patchAndFetch({
|
||||
active: params.input.active,
|
||||
});
|
||||
|
||||
const triggerStep = await flow.getTriggerStep();
|
||||
const trigger = await triggerStep.getTriggerCommand();
|
||||
const interval = trigger.getInterval?.(triggerStep.parameters);
|
||||
@@ -49,13 +47,13 @@ const updateFlowStatus = async (
|
||||
testRun: false,
|
||||
});
|
||||
|
||||
if (flow.active && trigger.registerHook) {
|
||||
if (newActiveValue && trigger.registerHook) {
|
||||
await trigger.registerHook($);
|
||||
} else if (!flow.active && trigger.unregisterHook) {
|
||||
} else if (!newActiveValue && trigger.unregisterHook) {
|
||||
await trigger.unregisterHook($);
|
||||
}
|
||||
} else {
|
||||
if (flow.active) {
|
||||
if (newActiveValue) {
|
||||
flow = await flow.$query().patchAndFetch({
|
||||
published_at: new Date().toISOString(),
|
||||
});
|
||||
@@ -80,6 +78,10 @@ const updateFlowStatus = async (
|
||||
}
|
||||
}
|
||||
|
||||
flow = await flow.$query().withGraphFetched('steps').patchAndFetch({
|
||||
active: newActiveValue,
|
||||
});
|
||||
|
||||
return flow;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user