Skip to content

Commit

Permalink
fix: SQL Lab show "Refetch Results" button while fetching new query r…
Browse files Browse the repository at this point in the history
…esults (apache#15109)

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

* fix comments
  • Loading branch information
Grace Guo authored and cccs-RyanS committed Dec 17, 2021
1 parent 2c0aae3 commit be6d1d4
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 @@ -517,7 +517,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 be6d1d4

Please sign in to comment.