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(
{url: url},

View File

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

View File

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

View File

@ -76,15 +76,15 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
};
const checkChosenProvider = () => currentProviderRadio().checked = true;
const showErrors = (err, warns) => {
const showErrors = (err, ...warns) => {
warns = warns || [];
backgroundPage.console.log('eeeEEEEE',warns)
const warning = warns
.map(
(w) => '✘ ' +
(w && w.clarification && w.clarification.message || w.message || '')
(w) =>
(w && (w.clarification && w.clarification.message || w.message) || '')
)
.filter( (m) => m )
.map( (m) => '✘ ' + m )
.join('<br/>');
let message = '';
@ -104,7 +104,7 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
}
setStatusTo(
`<span style="color:red">
${err ? '🔥&#xFE0E; Ошибка!' : 'Некритичная ошибка.'}
${err ? '🔥&#xFE0E; Ошибка!' : 'Некритичная ошибка.'}
</span>
<br/>
<span style="font-size: 0.9em; color: darkred">${message}</span>
@ -134,15 +134,15 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
setStatusTo(beforeStatus);
enableDisableInputs();
operation((err, res, warns) => {
if (err || warns) {
showErrors(err, warns);
operation((err, res, ...warns) => {
if (err || warns.length) {
showErrors(err, ...warns);
} else {
setStatusTo(afterStatus);
}
enableDisableInputs();
if (!err) {
onSuccess && onSuccess();
onSuccess && onSuccess(res);
}
});
@ -160,8 +160,8 @@ chrome.runtime.getBackgroundPage( (backgroundPage) =>
li.innerHTML = `
<input type="radio" name="pacProvider" id="${providerKey}">
<label for="${providerKey}"> ${provider.label}</label>
<a href class="link-button checked-radio-panel"
id="update-${providerKey}"> [обновить]</a>
&nbsp;<a href class="link-button checked-radio-panel"
id="update-${providerKey}">[обновить]</a>
<div class="desc">
<span class="info-sign">🛈</span>
<div class="tooltip">${provider.desc}</div>