From a880cdbc681056d2b7333271335bf51a4260d390 Mon Sep 17 00:00:00 2001 From: williamwoldum Date: Tue, 17 Jan 2023 12:50:08 +0100 Subject: [PATCH] silenced more request errors + small fix in display logic --- src/widgets/octoPrint/component.jsx | 12 ++++++------ src/widgets/octoPrint/proxy.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/widgets/octoPrint/component.jsx b/src/widgets/octoPrint/component.jsx index 4aa175de5..91890a60f 100644 --- a/src/widgets/octoPrint/component.jsx +++ b/src/widgets/octoPrint/component.jsx @@ -40,7 +40,9 @@ export default function Component({ service }) { ); } - if (printerStats === 500) { + const state = printerStats.state.text; + + if (state === "Not found" || Object.entries(printerStats.temperature).length === 0) { return ( @@ -48,14 +50,14 @@ export default function Component({ service }) { ); } - const state = printerStats.state.text; - if (state === "Printing" || state === "Paused") { if (jobStatsError) { return ; } - if (!jobStats) { + const { printTimeLeft, printTime, completion } = jobStats.progress; + + if (!jobStats || !printTimeLeft || !printTime || !completion) { return ( @@ -65,8 +67,6 @@ export default function Component({ service }) { ); } - const { printTimeLeft, printTime, completion } = jobStats.progress; - return ( <> diff --git a/src/widgets/octoPrint/proxy.js b/src/widgets/octoPrint/proxy.js index 8dd0f38fe..e634b9ddb 100644 --- a/src/widgets/octoPrint/proxy.js +++ b/src/widgets/octoPrint/proxy.js @@ -27,8 +27,8 @@ export default async function octoPrintProxyHandler(req, res, map) { let resultData = data; if (!validateWidgetData(widget, endpoint, resultData)) { - if (status === 500 && widget.silencePrinterNotFound) { - resultData = 500; + if ((status === 500 || status === 502 || status === 409) && widget.silencePrinterNotFound) { + resultData = { state: { text: "Not found" } }; return res.status(status).send(resultData); } return res.status(status).json({ error: { message: "Invalid data", url, data: resultData } });