Use callback during setState()

This commit is contained in:
Scott E. Graves committed 2018-11-13 13:27:37 -06:00
1 parent e4ca58e081
commit d8c5c769fd
3 files changed
+123 -118

No files matched your search

+28 -27
View File
@@ -164,11 +164,12 @@ class Configuration extends Component {
if (arg.data.Success) {
this.setState({
Template: arg.data.Template,
});
ipcRenderer.send(Constants.IPC_Get_Config, {
Directory: this.props.directory,
StorageType: this.props.storageType,
Version: this.props.version,
}, ()=> {
ipcRenderer.send(Constants.IPC_Get_Config, {
Directory: this.props.directory,
StorageType: this.props.storageType,
Version: this.props.version,
});
});
} else {
this.props.errorHandler(arg.data.Error, () => {
@@ -185,32 +186,32 @@ class Configuration extends Component {
if (ipcRenderer) {
this.setState({
Saving: true,
});
}, ()=> {
const changedItems = [];
for (const item of this.state.ChangedItems) {
changedItems.push({
Name: item.label,
Value: item.value,
});
}
const changedItems = [];
for (const item of this.state.ChangedItems) {
changedItems.push({
Name: item.label,
Value: item.value,
});
}
if (this.state.ChangedObjectLookup) {
for (const key of Object.keys(this.state.ChangedObjectLookup)) {
for (const item of this.state.ChangedObjectLookup[key]) {
changedItems.push({
Name: key + '.' + item.label,
Value: item.value,
});
if (this.state.ChangedObjectLookup) {
for (const key of Object.keys(this.state.ChangedObjectLookup)) {
for (const item of this.state.ChangedObjectLookup[key]) {
changedItems.push({
Name: key + '.' + item.label,
Value: item.value,
});
}
}
}
}
ipcRenderer.send(Constants.IPC_Set_Config_Values, {
Directory: this.props.directory,
Items: changedItems,
StorageType: this.props.storageType,
Version: this.props.version,
ipcRenderer.send(Constants.IPC_Set_Config_Values, {
Directory: this.props.directory,
Items: changedItems,
StorageType: this.props.storageType,
Version: this.props.version,
});
});
}
};