From 2f2b1f8d708c086c550ea757844973df892dbfd1 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Thu, 19 May 2022 08:00:25 +0530 Subject: [PATCH] SDA-3705 - Render network error once (#1425) --- package-lock.json | 18 +++++++++--------- src/renderer/preload-main.ts | 12 ++++++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index ded38369..f9e4e09d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4426,7 +4426,7 @@ "dependencies": { "escape-string-regexp": { "version": "1.0.5", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true } @@ -5226,7 +5226,7 @@ }, "css-value": { "version": "0.0.1", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/css-value/-/css-value-0.0.1.tgz", + "resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", "dev": true }, @@ -5713,7 +5713,7 @@ }, "dev-null": { "version": "0.1.1", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/dev-null/-/dev-null-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/dev-null/-/dev-null-0.1.1.tgz", "integrity": "sha1-WiBc48Ky73e2I41roXnrdMag6Bg=", "dev": true }, @@ -11937,7 +11937,7 @@ }, "lodash.isobject": { "version": "3.0.2", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/lodash.isobject/-/lodash.isobject-3.0.2.tgz", + "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz", "integrity": "sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0=", "dev": true }, @@ -11989,7 +11989,7 @@ }, "lodash.zip": { "version": "4.2.0", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/lodash.zip/-/lodash.zip-4.2.0.tgz", + "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz", "integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=", "dev": true }, @@ -12943,19 +12943,19 @@ "dependencies": { "tr46": { "version": "0.0.3", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/tr46/-/tr46-0.0.3.tgz", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, "webidl-conversions": { "version": "3.0.1", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", "dev": true }, "whatwg-url": { "version": "5.0.0", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/whatwg-url/-/whatwg-url-5.0.0.tgz", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", "dev": true, "requires": { @@ -15367,7 +15367,7 @@ "dependencies": { "fast-deep-equal": { "version": "2.0.1", - "resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true } diff --git a/src/renderer/preload-main.ts b/src/renderer/preload-main.ts index e26e2c54..a3a8b9f6 100644 --- a/src/renderer/preload-main.ts +++ b/src/renderer/preload-main.ts @@ -150,10 +150,14 @@ ipcRenderer.on('page-load-failed', (_event, { locale, resources }) => { // Injects network error content into the DOM ipcRenderer.on('network-error', (_event, { error }) => { - const networkErrorContainer = document.createElement('div'); - networkErrorContainer.id = 'main-frame'; - networkErrorContainer.classList.add('content-wrapper'); - document.body.append(networkErrorContainer); + let networkErrorContainer = document.getElementById('main-frame'); + // prevents duplicate rendering of the NetworkError + if (!networkErrorContainer) { + networkErrorContainer = document.createElement('div'); + networkErrorContainer.id = 'main-frame'; + networkErrorContainer.classList.add('content-wrapper'); + document.body.append(networkErrorContainer); + } const networkError = React.createElement(NetworkError, { error }); ReactDOM.render(networkError, networkErrorContainer); });