Skip to content

Commit

Permalink
keep previous result
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Nov 14, 2024
1 parent c20c041 commit 2edde87
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR
shouldUpdateState = true;
if (next.chartData && next.chartData !== fetchState.chartData) shouldUpdateState = true;
// we still want to show rows from the previous query while current query is loading
if (next.status !== ResultStatus.LOADING && next.rows && next.rows !== fetchState.rows) {
if (
next.status !== ResultStatus.LOADING &&
next.status !== ResultStatus.ERROR &&
next.rows &&
next.rows !== fetchState.rows
) {
shouldUpdateState = true;
setRows(next.rows);
}
Expand Down Expand Up @@ -152,20 +157,13 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR
timeFieldName={timeField}
/>
)}
{fetchState.status === ResultStatus.ERROR && (
<DiscoverNoResults
queryString={data.query.queryString}
query={data.query.queryString.getQuery()}
savedQuery={data.query.savedQueries}
timeFieldName={timeField}
/>
)}
{fetchState.status === ResultStatus.UNINITIALIZED && (
<DiscoverUninitialized onRefresh={() => refetch$.next()} />
)}
{fetchState.status === ResultStatus.LOADING && !rows?.length && <LoadingSpinner />}
{(fetchState.status === ResultStatus.READY ||
(fetchState.status === ResultStatus.LOADING && !!rows?.length)) &&
(fetchState.status === ResultStatus.LOADING && !!rows?.length) ||
fetchState.status === ResultStatus.ERROR) &&
(isEnhancementsEnabled ? (
<>
<MemoizedDiscoverChartContainer {...fetchState} />
Expand Down

0 comments on commit 2edde87

Please sign in to comment.