Fix bug with InfernoJS

This commit is contained in:
Ilya Ig. Petrov 2017-05-26 07:35:04 -07:00
parent aa7081cdda
commit 40f5f134e1
3 changed files with 18 additions and 10 deletions

View File

@ -80,7 +80,6 @@ export default function getMain(theState) {
if (targetIndex !== index) {
return conf;
}
console.log(`${conf.key} := ${newValue}`);
return Object.assign({}, conf, {
value: newValue
});

View File

@ -20,10 +20,8 @@ export default function getModList(theState) {
handleCheck(confMeta, ifChecked) {
console.log('handle CHECK:', ifChecked);
this.state.checks[confMeta.index] = ifChecked;
if (ifChecked === false || !confMeta.ifChild) {
console.log('NO CHILD OR FALSE', confMeta);
this.handleNewValue(confMeta, ifChecked);
} else {
this.setState({
@ -37,7 +35,6 @@ export default function getModList(theState) {
handleNewValue({ conf, index }, newValue) {
console.log('handle NEW VALUE', conf.key, newValue);
this.props.onConfChanged({
targetConf: conf,
targetIndex: index,
@ -62,7 +59,6 @@ export default function getModList(theState) {
Object.assign({}, props, {conf, onNewValue: (newValue) => this.handleNewValue(confMeta, newValue)})
);
console.log('CHIIIIILD', child);
return (<InfoLi
conf={conf}
type='checkbox'

View File

@ -460,12 +460,13 @@ PROXY foobar.com:8080; # Not HTTP!`.trim()}
}
let waitingNewValues = [];
return class ProxyEditor extends Component {
constructor(props/*{ conf, onNewValue, ifInputsDisabled }*/) {
super(props);
console.log('CONSTRUCTOR')
const oldValue = typeof props.conf.value === 'string' && props.conf.value;
const newValue = oldValue || localStorage.getItem(UI_RAW) || '';
this.state = {
@ -473,17 +474,30 @@ PROXY foobar.com:8080; # Not HTTP!`.trim()}
ifExportsMode: false,
};
this.handleSwitch = () => this.setState({ifExportsMode: !this.state.ifExportsMode});
this.mayEmitNewValue(oldValue, newValue);
waitingNewValues.push(newValue); // Wait till mount or eat bugs.
}
componentDidMount() {
if (waitingNewValues.length) {
this.mayEmitNewValue(this.props.value, waitingNewValues.pop());
waitingNewValues = [];
}
}
componentDidUnmount() {
waitingNewValues = [];
}
mayEmitNewValue(oldValue, newValue) {
console.log('emit?', oldValue, 'vs', newValue);
if ( // Reject: 1) both `false` OR 2) both `===`.
( Boolean(oldValue) || Boolean(newValue) ) && oldValue !== newValue
) {
console.log('EMIT');
this.props.onNewValue(newValue);
}
@ -504,7 +518,6 @@ PROXY foobar.com:8080; # Not HTTP!`.trim()}
},
}, originalProps);
return createElement(ExportsEditor, props);
return this.state.ifExportsMode
? createElement(ExportsEditor, props)
: createElement(TabledEditor, props);