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 (#15109)

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

* fix comments
  • Loading branch information
Grace Guo committed Jun 16, 2021
1 parent 91e424b commit 408d58f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion superset-frontend/src/SqlLab/reducers/sqlLab.js
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 408d58f

Please sign in to comment.