Skip to content

Commit

Permalink
Use a state variable for loading flag
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam authored and timopollmeier committed Dec 11, 2023
1 parent 483aea0 commit 487b94a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/web/pages/tags/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class TagDialog extends React.Component {
super(...args);

const {resource_ids = []} = this.props;
this.isLoading = false;

this.state = {
resourceIdText: '',
resourceIdsSelected: resource_ids,
resourceOptions: [],
resourceType: this.props.resource_type,
isLoading: false,
};
}

Expand All @@ -99,7 +99,9 @@ class TagDialog extends React.Component {
return;
}
const {gmp} = this.props;
this.isLoading = true;
this.setState({
isLoading: true,
});
gmp.resourcenames
.getAll({resource_type: convertType(type)})
.then(response => {
Expand All @@ -115,13 +117,15 @@ class TagDialog extends React.Component {
if (isEmpty(id)) {
id = undefined;
}
this.isLoading = false;
this.setState({
resourceOptions: data,
isLoading: false,
});
})
.catch(err => {
this.isLoading = false;
this.setState({
isLoading: false,
});
throw err;
});
}
Expand Down Expand Up @@ -292,7 +296,7 @@ class TagDialog extends React.Component {
resourceTypesOptions.length === 0
}
isLoading={
this.isLoading &&
this.state.isLoading &&
this.state.resourceOptions.length === 0
}
onChange={ids => this.handleIdChange(ids, onValueChange)}
Expand Down

0 comments on commit 487b94a

Please sign in to comment.