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) { if (targetIndex !== index) {
return conf; return conf;
} }
console.log(`${conf.key} := ${newValue}`);
return Object.assign({}, conf, { return Object.assign({}, conf, {
value: newValue value: newValue
}); });

View File

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

View File

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