From ea90ac4c6b9d3440e89383e6ab0990be15fa7b53 Mon Sep 17 00:00:00 2001 From: Stanislav Fifik Date: Wed, 19 Apr 2023 12:42:18 +0200 Subject: [PATCH] :bug: api now waits for all connected inputs to have value --- package.json | 2 +- src/nodes/Api.ts | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d9c7fef..4f5b2e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphfx", - "version": "0.4.3", + "version": "0.4.4", "description": "Graph image processing pipeline", "main": "src/index.ts", "scripts": { diff --git a/src/nodes/Api.ts b/src/nodes/Api.ts index ecb4db6..54fa5cb 100644 --- a/src/nodes/Api.ts +++ b/src/nodes/Api.ts @@ -84,7 +84,7 @@ export default class Api extends Node { } async _update() { - if (!this.in.url.value) { + if (!this.canUpdate()) { return; } @@ -102,6 +102,31 @@ export default class Api extends Node { } } + private canUpdate(): boolean { + if (!this.in.url.value) { + return false + } + + const inputs = [ + 'image0', + 'image1', + 'image2', + 'image3', + 'image4', + 'image5', + 'image6', + 'image7', + ] + + for(const input of inputs) { + if (this.in[input].output && !this.in[input].value) { + return false + } + } + + return true; + } + private async upload(): Promise { const formData = await this.createFormData();