Skip to content

Commit

Permalink
fix(QT): fix result tabs switching when polling [YTFRONT-3840]
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Shishov committed Oct 28, 2023
1 parent 180fc73 commit ec1db61
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {TabsItemProps} from '@gravity-ui/uikit';
import times_ from 'lodash/times';
import has_ from 'lodash/has';
import {QueryItem, QueryStatus} from '../../module/api';
import find_ from 'lodash/find';
import {CompletedStates, QueryItem, QueryStatus} from '../../module/api';
import {QueryStatusIcon} from '../../QueryStatus';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {useDispatch, useSelector} from 'react-redux';
Expand Down Expand Up @@ -111,12 +112,14 @@ export const useQueryResultTabs = (
return items;
}, [query, resultsMeta]);

const isCompleted = find_(CompletedStates, (status) => query?.state === status);

useEffect(() => {
if (query) {
dispatch(loadQueryResultsErrors(query));
}
setActiveTab(tabs?.[0]?.id, query?.id);
}, [dispatch, query]);
}, [dispatch, query?.id, isCompleted]);

return [
tabs,
Expand Down

0 comments on commit ec1db61

Please sign in to comment.