Change [warns] to ...warns

This commit is contained in:
Ilya Ig. Petrov 2017-01-17 16:39:03 +00:00
parent a9eef144a9
commit 170b101a48
5 changed files with 34 additions and 31 deletions

View File

@ -47,7 +47,7 @@
} }
const openAndFocus = (url) => { const openAndFocus = function openAndFocus(url) {
chrome.tabs.create( chrome.tabs.create(
{url: url}, {url: url},

View File

@ -225,13 +225,13 @@
return cb(v4err, v4res); return cb(v4err, v4res);
} }
const ips = v4res; const ips = v4res;
let warns = null; let warns = [];
if (!v6err) { if (!v6err) {
ips.push(...v6res); ips.push(...v6res);
} else { } else {
warns = [v6err]; warns = [v6err];
} }
cb(null, ips, warns); cb(null, ips, ...warns);
} }
); );
@ -254,7 +254,7 @@
provider.proxyHosts.forEach( provider.proxyHosts.forEach(
(proxyHost) => getIpsFor( (proxyHost) => getIpsFor(
proxyHost, proxyHost,
(err, ips, warns) => { (err, ips, ...warns) => {
if (!err) { if (!err) {
provider.proxyIps = provider.proxyIps || {}; provider.proxyIps = provider.proxyIps || {};
@ -262,7 +262,7 @@
(ip) => provider.proxyIps[ip] = proxyHost (ip) => provider.proxyIps[ip] = proxyHost
); );
} }
if (err || warns) { if (err || warns.length) {
failure.errors[proxyHost] = err || warns; failure.errors[proxyHost] = err || warns;
} }
@ -282,7 +282,7 @@
); );
errorsCount === hostsProcessed errorsCount === hostsProcessed
? cb(failure) ? cb(failure)
: cb(null, null, [failure]); : cb(null, null, failure);
} }
) )
); );
@ -305,10 +305,10 @@
return cb( return cb(
null, null,
{lastModified}, {lastModified},
[new Warning( new Warning(
'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' + 'Ваш PAC-скрипт не нуждается в обновлении. Его дата: ' +
lastModified lastModified
)] )
); );
} }
@ -519,7 +519,7 @@
(resolve, reject) => setPacScriptFromProviderAsync( (resolve, reject) => setPacScriptFromProviderAsync(
pacProvider, pacProvider,
this.getLastModifiedForKey(key), this.getLastModifiedForKey(key),
(err, res, warns) => { (err, res, ...warns) => {
if (!err) { if (!err) {
this.setCurrentPacProviderKey(key, res.lastModified); this.setCurrentPacProviderKey(key, res.lastModified);
@ -528,7 +528,7 @@
this.setAlarms(); this.setAlarms();
} }
resolve([err, null, warns]); resolve([err, null, ...warns]);
} }
) )
@ -542,17 +542,17 @@
); );
Promise.all([pacSetPromise, ipsErrorPromise]).then( Promise.all([pacSetPromise, ipsErrorPromise]).then(
([[pacErr, pacRes, pacWarns], ipsErr]) => { ([[pacErr, pacRes, ...pacWarns], ipsErr]) => {
if (pacErr && ipsErr) { if (pacErr && ipsErr) {
return cb(pacErr, pacRes); return cb(pacErr, pacRes);
} }
let warns = [...(pacWarns || []), ipsErr].filter( (_) => _ ); const warns = pacWarns;
if (!warns.length) { if (ipsErr) {
warns = null; warns.push(ipsErr)
} }
this.pushToStorageAsync( this.pushToStorageAsync(
(pushErr) => cb(pacErr || pushErr, null, warns) (pushErr) => cb(pacErr || pushErr, null, ...warns)
); );
}, },

View File

@ -4,7 +4,8 @@
(e.g. popup) to background window, so we may catch errors (e.g. popup) to background window, so we may catch errors
in bg error handlers. in bg error handlers.
More: https://bugs.chromium.org/p/chromium/issues/detail?id=357568 More: https://bugs.chromium.org/p/chromium/issues/detail?id=357568
setTimeout is applied to Async methods only (name ends with Async) setTimeout is applied to Async/Void methods
only (name ends with Async/Void)
*/ */
// Fix error context of methods of all APIs. // Fix error context of methods of all APIs.

View File

@ -30,6 +30,7 @@
input[type="radio"], label { input[type="radio"], label {
cursor: pointer; cursor: pointer;
} }
.link-button, .link-button:visited { .link-button, .link-button:visited {
color: #0000EE; color: #0000EE;
text-decoration: none; text-decoration: none;
@ -37,6 +38,7 @@
.link-button:hover { .link-button:hover {
text-decoration: underline; text-decoration: underline;
} }
.checked-radio-panel { .checked-radio-panel {
visibility: hidden; visibility: hidden;
} }
@ -132,6 +134,7 @@
#custom-proxy-string-raw:not(:checked) ~ textarea { #custom-proxy-string-raw:not(:checked) ~ textarea {
display: none; display: none;
} }
.control-row { .control-row {
display: table; display: table;
width: 100%; width: 100%;
@ -141,7 +144,6 @@
display: table-cell; display: table-cell;
} }
.control-row a:nth-child(2) { .control-row a:nth-child(2) {
text-decoration: none;
margin-left: 1em; margin-left: 1em;
text-align: right; text-align: right;
} }
@ -164,7 +166,7 @@
<ul id="pac-mods"> <ul id="pac-mods">
<li class="control-row"> <li class="control-row">
<input type="button" value="Применить" id="apply-mods" disabled/> <input type="button" value="Применить" id="apply-mods" disabled/>
<a href id="reset-mods">К изначальным!</a> <a href id="reset-mods" class="link-button">К изначальным!</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -176,7 +178,7 @@
</div> </div>
<footer class="control-row"> <footer class="control-row">
<input type="button" value="Готово" class="close-button"> <input type="button" value="Готово" class="close-button">
<a href="../troubleshoot/index.html"> <a href="../troubleshoot/index.html" class="link-button">
Проблемы? Проблемы?
</a> </a>
</footer> </footer>

View File

@ -76,15 +76,15 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
}; };
const checkChosenProvider = () => currentProviderRadio().checked = true; const checkChosenProvider = () => currentProviderRadio().checked = true;
const showErrors = (err, warns) => { const showErrors = (err, ...warns) => {
warns = warns || [];
backgroundPage.console.log('eeeEEEEE',warns)
const warning = warns const warning = warns
.map( .map(
(w) => '✘ ' + (w) =>
(w && w.clarification && w.clarification.message || w.message || '') (w && (w.clarification && w.clarification.message || w.message) || '')
) )
.filter( (m) => m )
.map( (m) => '✘ ' + m )
.join('<br/>'); .join('<br/>');
let message = ''; let message = '';
@ -134,15 +134,15 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
setStatusTo(beforeStatus); setStatusTo(beforeStatus);
enableDisableInputs(); enableDisableInputs();
operation((err, res, warns) => { operation((err, res, ...warns) => {
if (err || warns) { if (err || warns.length) {
showErrors(err, warns); showErrors(err, ...warns);
} else { } else {
setStatusTo(afterStatus); setStatusTo(afterStatus);
} }
enableDisableInputs(); enableDisableInputs();
if (!err) { if (!err) {
onSuccess && onSuccess(); onSuccess && onSuccess(res);
} }
}); });
@ -160,7 +160,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
li.innerHTML = ` li.innerHTML = `
<input type="radio" name="pacProvider" id="${providerKey}"> <input type="radio" name="pacProvider" id="${providerKey}">
<label for="${providerKey}"> ${provider.label}</label> <label for="${providerKey}"> ${provider.label}</label>
<a href class="link-button checked-radio-panel" &nbsp;<a href class="link-button checked-radio-panel"
id="update-${providerKey}">[обновить]</a> id="update-${providerKey}">[обновить]</a>
<div class="desc"> <div class="desc">
<span class="info-sign">🛈</span> <span class="info-sign">🛈</span>