silenced more request errors + small fix in display logic

pull/834/head
williamwoldum 2 years ago
parent 9f008fc04e
commit a880cdbc68

@ -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 (
<Container service={service}>
<Block label="octoPrint.printer_state" value={printerStats.state.text} />
@ -48,14 +50,14 @@ export default function Component({ service }) {
);
}
const state = printerStats.state.text;
if (state === "Printing" || state === "Paused") {
if (jobStatsError) {
return <Container error={jobStatsError} />;
}
if (!jobStats) {
const { printTimeLeft, printTime, completion } = jobStats.progress;
if (!jobStats || !printTimeLeft || !printTime || !completion) {
return (
<Container service={service}>
<Block label="octoPrint.job_time_elapsed" />
@ -65,8 +67,6 @@ export default function Component({ service }) {
);
}
const { printTimeLeft, printTime, completion } = jobStats.progress;
return (
<>
<Container service={service}>

@ -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 } });

Loading…
Cancel
Save