From cb7663840b671346ce5d438e357e98ae5d2a616c Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Thu, 22 Aug 2019 16:29:19 +0200 Subject: [PATCH] Show a dummy icon in case loading fails --- packages/common/vpu-icon.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/common/vpu-icon.js b/packages/common/vpu-icon.js index 79865d19..48ecdd06 100644 --- a/packages/common/vpu-icon.js +++ b/packages/common/vpu-icon.js @@ -30,10 +30,13 @@ class Icon extends LitElement { } render() { - let path = fetch('local/vpu-common/icons/' + this.name + '.json') + let iconPath = 'local/vpu-common2/icons/' + this.name + '.json'; + let svgPath = fetch(iconPath) .then(response => { - if (!response.ok) - throw Error(response.statusText); + if (!response.ok) { + console.error("Failed to load icon: " + this.name); + return "M0,0H24V24H0"; + } return response.json(); }); @@ -46,7 +49,7 @@ class Icon extends LitElement { <svg aria-labelledby="title" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="pointer-events: none; display: block; width: 100%; height: 100%;"> <title id="title">${this.name}</title> - <path d=${until(path)} /> + <path d=${until(svgPath)} /> </svg> `; } -- GitLab