Fix reduce no zero index bug

This commit is contained in:
Ilya Ig. Petrov 2017-06-01 16:02:50 +05:00
parent 5a1f788247
commit 82c155f662
4 changed files with 12 additions and 13 deletions

View File

@ -123,9 +123,10 @@
const conf = configs[key]; const conf = configs[key];
if(typeof(conf.order) === 'number') { if(typeof(conf.order) === 'number') {
if(!category || category === (conf.category || 'general')) { if(!category || category === (conf.category || 'general')) {
arr.push(conf);
conf.value = pacMods[key]; conf.value = pacMods[key];
conf.key = key; conf.key = key;
conf.category = category || 'general';
arr.push(conf);
} }
} }
return arr; return arr;
@ -433,15 +434,12 @@ ${ pacMods.filteredCustomsString
const oldProxies = getCurrentConfigs().filteredCustomsString || ''; const oldProxies = getCurrentConfigs().filteredCustomsString || '';
const newProxies = pacMods.filteredCustomsString || ''; const newProxies = pacMods.filteredCustomsString || '';
ifProxiesChanged = oldProxies !== newProxies; ifProxiesChanged = oldProxies !== newProxies;
console.log('Proxies changed from:', oldProxies, 'to', newProxies);
kitchenState(modsKey, pacMods); kitchenState(modsKey, pacMods);
} }
console.log('Keep cooked now...', pacMods);
this.setNowAsync( this.setNowAsync(
(err, res, ...setWarns) => { (err, res, ...setWarns) => {
const accWarns = modsWarns.concat(setWarns); // Acc = accumulated. const accWarns = modsWarns.concat(setWarns); // Acc = accumulated.
console.log('Try now err:', err);
if (err) { if (err) {
return cb(err, res, ...accWarns); return cb(err, res, ...accWarns);
} }

View File

@ -25,6 +25,11 @@ export default function getApp(theState) {
hashParams: hashParams, hashParams: hashParams,
}; };
this.setStatusTo = this.setStatusTo.bind(this);
this.conduct = this.conduct.bind(this);
this.showErrors = this.showErrors.bind(this);
this.showNews = this.showNews.bind(this);
} }
setStatusTo(msg, cb) { setStatusTo(msg, cb) {
@ -75,7 +80,6 @@ export default function getApp(theState) {
}; };
const ghUrl = `https://api.github.com/repos/edge-ware/edge-ware.github.io/issues/1/comments${query}`; const ghUrl = `https://api.github.com/repos/edge-ware/edge-ware.github.io/issues/1/comments${query}`;
console.log(ghUrl);
const [comments, etag] = await fetch( const [comments, etag] = await fetch(
ghUrl, ghUrl,
params params
@ -248,10 +252,10 @@ export default function getApp(theState) {
console.log('Render'); console.log('Render');
const props = Object.assign({}, originalProps, { const props = Object.assign({}, originalProps, {
funs: { funs: {
setStatusTo: this.setStatusTo.bind(this), setStatusTo: this.setStatusTo,
conduct: this.conduct.bind(this), conduct: this.conduct,
showErrors: this.showErrors.bind(this), showErrors: this.showErrors,
showNews: this.showNews.bind(this), showNews: this.showNews,
}, },
ifInputsDisabled: this.state.ifInputsDisabled, ifInputsDisabled: this.state.ifInputsDisabled,
hashParams: this.state.hashParams, hashParams: this.state.hashParams,

View File

@ -55,7 +55,7 @@ export default function getMain(theState) {
modsMutated[conf.key] = conf.value; modsMutated[conf.key] = conf.value;
return modsMutated; return modsMutated;
}); }, modsMutated/*< Needed for index 0*/);
that.props.funs.conduct( that.props.funs.conduct(
'Применяем настройки...', 'Применяем настройки...',
(cb) => that.props.apis.pacKitchen.keepCookedNowAsync(newMods, cb), (cb) => that.props.apis.pacKitchen.keepCookedNowAsync(newMods, cb),
@ -67,7 +67,6 @@ export default function getMain(theState) {
handleModChange({targetConf, targetIndex, newValue}) { handleModChange({targetConf, targetIndex, newValue}) {
console.log('NEW VALUE', newValue);
const oldCats = this.state.catToOrderedMods; const oldCats = this.state.catToOrderedMods;
const newCats = Object.keys(this.state.catToOrderedMods).reduce((acc, cat) => { const newCats = Object.keys(this.state.catToOrderedMods).reduce((acc, cat) => {

View File

@ -207,7 +207,6 @@ export default function getProxyEditor(theState) {
handleAdd(that, event) { handleAdd(that, event) {
console.log('handle add');
const form = event.target; const form = event.target;
const elements = Array.from(form.elements).reduce((acc, el, index) => { const elements = Array.from(form.elements).reduce((acc, el, index) => {
@ -222,7 +221,6 @@ export default function getProxyEditor(theState) {
const newValue = `${that.props.proxyStringRaw}; ${type} ${hostname}:${port}` const newValue = `${that.props.proxyStringRaw}; ${type} ${hostname}:${port}`
.trim().replace(/(\s*;\s*)+/, '; '); .trim().replace(/(\s*;\s*)+/, '; ');
console.log('NEW VALUE', newValue);
that.props.setProxyStringRaw(newValue); that.props.setProxyStringRaw(newValue);
} }