Skip to content

Commit

Permalink
fix: sql lab refetch button (#16469)
Browse files Browse the repository at this point in the history
* fix: SQL Lab show "Refetch Results" button while fetching new query results (#15109)

* fix: SQL Lab show "Refetch Results" button while fetching new query results

* fix comments

(cherry picked from commit 408d58f)

* handle exception caused by invalid query id
  • Loading branch information
Grace Guo authored Aug 30, 2021
1 parent 8aa24e5 commit 2199f65
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,20 @@ export default function sqlLabReducer(state = {}, action) {
if (changedQuery.changedOn > queriesLastUpdate) {
queriesLastUpdate = changedQuery.changedOn;
}
newQueries[id] = { ...state.queries[id], ...changedQuery };
const prevState = state.queries[id]?.state;
const currentState = changedQuery.state;
newQueries[id] = {
...state.queries[id],
...changedQuery,
// race condition:
// because of async behavior, sql lab may still poll a couple of seconds
// when it started fetching or finished rendering results
state:
currentState === 'success' &&
['fetching', 'success'].includes(prevState)
? prevState
: currentState,
};
change = true;
}
});
Expand Down

0 comments on commit 2199f65

Please sign in to comment.