From d02e5321869171f46a692e01a73553744c4da2c6 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sat, 3 Jun 2017 21:54:34 +0500 Subject: [PATCH] Make news error non-critical, make it more verbose --- .../pages/options/src/components/App.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/App.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/App.js index 34cd4dc..270cd20 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/App.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/App.js @@ -96,7 +96,8 @@ export default function getApp(theState) { ]), (err) => { - this.showErrors({message: 'Не удалось достать новости: что-то не так с сетью.', wrapped: err}); + const ifCritical = null; + this.showErrors(ifCritical, {message: 'Не удалось достать новости: что-то не так с сетью.', wrapped: err}); return [err, false, false]; } @@ -177,18 +178,11 @@ export default function getApp(theState) { : () => {}; const warns = args; - const warningHtml = warns - .map( - (w) => w && w.message || '' - ) - .filter( (m) => m ) - .map( (m) => '✘ ' + m ) - .join('
'); + const errToHtmlMessage = (error) => { - let messageHtml = ''; - if (err) { - let wrapped = err.wrapped; - messageHtml = err.message || ''; + let messageHtml = ''; + let wrapped = error.wrapped; + messageHtml = error.message || ''; while( wrapped ) { const deeperMsg = wrapped && wrapped.message; @@ -197,7 +191,20 @@ export default function getApp(theState) { } wrapped = wrapped.wrapped; } - } + return messageHtml; + + }; + + let messageHtml = err ? errToHtmlMessage(err) : ''; + + const warningHtml = warns + .filter((w) => w) + .map( + (w) => errToHtmlMessage(w) + ) + .map( (m) => '✘ ' + m ) + .join('
'); + messageHtml = messageHtml.trim(); if (warningHtml) { messageHtml = messageHtml ? messageHtml + '
' + warningHtml : warningHtml;