Skip to content

Commit

Permalink
Update ToggleButton query behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
metagrover committed Sep 26, 2017
1 parent e637354 commit 1077f54
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/sensors/ToggleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,20 @@ export default class ToggleButton extends Component {
// set the query type and input data
setQueryInfo(props) {
const getQuery = (value) => {
const currentQuery = props.customQuery ? props.customQuery(value) : this.customQuery(value);
if (this.props.onQueryChange && JSON.stringify(this.previousQuery) !== JSON.stringify(currentQuery)) {
this.props.onQueryChange(this.previousQuery, currentQuery);
if (Array.isArray(value)) {
const currentQuery = props.customQuery ? props.customQuery(value) : this.customQuery(value);
if (this.props.onQueryChange && JSON.stringify(this.previousQuery) !== JSON.stringify(currentQuery)) {
this.props.onQueryChange(this.previousQuery, currentQuery);
}
this.previousQuery = currentQuery;
return currentQuery;
} else {
const currentQuery = null;
if (this.props.onQueryChange && JSON.stringify(this.previousQuery) !== JSON.stringify(currentQuery)) {
this.props.onQueryChange(this.previousQuery, currentQuery);
}
return currentQuery;
}
this.previousQuery = currentQuery;
return currentQuery;
};
const obj = {
key: props.componentId,
Expand Down

0 comments on commit 1077f54

Please sign in to comment.