Skip to content

Commit

Permalink
Do not allow cancel the same query twice
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcnunes committed Nov 6, 2016
1 parent c147c62 commit 662c312
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderer/components/query.jsx
Original file line number Diff line number Diff line change
@@ -300,7 +300,7 @@ export default class Query extends Component {
query.isExecuting && allowCancel
? (
<button
className="ui negative button"
className={`ui negative button ${query.isCanceling ? 'loading' : ''}`}
onClick={::this.onCancelQueryClick}>Cancel</button>
)
: (
19 changes: 19 additions & 0 deletions src/renderer/reducers/queries.js
Original file line number Diff line number Diff line change
@@ -77,6 +77,25 @@ export default function (state = INITIAL_STATE, action) {
error: action.error,
});
}
case types.CANCEL_QUERY_REQUEST: {
return changeStateByCurrentQuery(state, {
isCanceling: true,
});
}
case types.CANCEL_QUERY_SUCCESS: {
return changeStateByCurrentQuery(state, {
error: null,
isCanceling: false,
});
}
case types.CANCEL_QUERY_FAILURE: {
return changeStateByCurrentQuery(state, {
results: null,
isExecuting: false,
isCanceling: false,
error: action.error,
});
}
case types.UPDATE_QUERY: {
return changeStateByCurrentQuery(state, {
query: action.query,

0 comments on commit 662c312

Please sign in to comment.