Skip to content

Commit

Permalink
fixup refetching
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Jul 31, 2023
1 parent 1f46bf5 commit 1e7cd7c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {useContext, useEffect, useState} from 'react';

import {Select, Space, Tabs} from 'antd';

import {BaseQueryFn, FetchBaseQueryError, MutationDefinition} from '@reduxjs/toolkit/dist/query';
import {MutationDefinition} from '@reduxjs/toolkit/dist/query';
import {MutationTrigger} from '@reduxjs/toolkit/dist/query/react/buildHooks';

import {ExecutorIcon} from '@atoms';
Expand Down Expand Up @@ -69,10 +69,7 @@ const EntityDetailsContent: React.FC = () => {
const [runTest] = useRunTestMutation();
const [runTestSuite] = useRunTestSuiteMutation();

const runRequestsMap: Record<
Entity,
MutationTrigger<MutationDefinition<any, BaseQueryFn<any, unknown, FetchBaseQueryError>, never, void, string>>
> = {
const runRequestsMap: Record<Entity, MutationTrigger<MutationDefinition<any, any, any, void>>> = {
'test-suites': runTestSuite,
tests: runTest,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const namingMap: Record<Entity, string> = {
tests: 'test',
};

export const updateRequestsMap: Record<Entity, UseMutation<MutationDefinition<any, any, never, void>>> = {
export const updateRequestsMap: Record<Entity, UseMutation<MutationDefinition<any, any, any, void>>> = {
'test-suites': useUpdateTestSuiteMutation,
tests: useUpdateTestMutation,
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ExecutionDetailsDrawer: React.FC = () => {
pollingInterval: PollingIntervals.everySecond,
skip: !isClusterAvailable || !id || isExecutionFinished(data),
});
useExecutionDetailsSync({data: fetchedData, error});
useExecutionDetailsSync({data: fetchedData?.id === id ? fetchedData : null, error});

const isMobile = useIsMobile();

Expand Down
2 changes: 1 addition & 1 deletion src/utils/isExecutionFinished.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import {TestSuiteExecution} from '@models/testSuiteExecution';

export function isExecutionFinished(data: TestSuiteExecution | Execution | null | undefined): boolean {
const status = (data as Execution)?.executionResult?.status || (data as TestSuiteExecution)?.status;
return ['queued', 'pending', 'running'].includes(status);
return Boolean(status) && !['queued', 'pending', 'running'].includes(status);
}

0 comments on commit 1e7cd7c

Please sign in to comment.