Skip to content

Commit 7154385

Browse files
fixed rendering issue after polling while sorting
1 parent 3c946b8 commit 7154385

File tree

5 files changed

+59
-39
lines changed

5 files changed

+59
-39
lines changed

src/ui/layouts/pipelines/Pipelines/List/useService.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const useService = (
4141
}[],
4242
): ServiceInterface => {
4343
const [activeSorting, setActiveSorting] = React.useState<Sorting | null>(
44-
'createdAt',
44+
null,
4545
);
4646
const [
4747
activeSortingDirection,
@@ -78,13 +78,16 @@ export const useService = (
7878
}, [filter, pipelines]);
7979

8080
useEffect(() => {
81-
const intervalId = setInterval(() => {
82-
//assign interval to a variable to clear it.
81+
if (activeSorting === null) {
82+
const intervalId = setInterval(() => {
83+
//assign interval to a variable to clear it.
8384

84-
dispatch(pipelinesActions.getMy({}));
85-
}, 5000);
85+
dispatch(pipelinesActions.getMy({}));
86+
}, 5000);
8687

87-
return () => clearInterval(intervalId); //This is important
88+
return () => clearInterval(intervalId);
89+
}
90+
//This is important
8891
});
8992

9093
const setSelectedRunIds = (runIds: TId[]) => {

src/ui/layouts/stackComponents/Stacks/List/useService.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import _ from 'lodash';
44
import React from 'react';
55
import { useEffect, useState } from 'react';
66
import { useDispatch, useSelector } from 'react-redux';
7-
import { stackPagesActions } from '../../../../../redux/actions';
7+
import {
8+
stackComponentsActions,
9+
stackPagesActions,
10+
} from '../../../../../redux/actions';
811
import {
912
stackComponentSelectors,
1013
stackPagesSelectors,
1114
stackSelectors,
1215
} from '../../../../../redux/selectors';
1316
import { getFilteredDataForTable } from '../../../../../utils/tableFilters';
17+
import { useLocationPath } from '../../../../hooks';
1418
import { Sorting, SortingDirection } from './ForSorting/types';
1519

1620
interface ServiceInterface {
@@ -39,14 +43,14 @@ export const useService = (
3943
}[],
4044
): ServiceInterface => {
4145
const [activeSorting, setActiveSorting] = React.useState<Sorting | null>(
42-
'createdAt',
46+
null,
4347
);
4448
const [
4549
activeSortingDirection,
4650
setActiveSortingDirection,
4751
] = React.useState<SortingDirection | null>('DESC');
4852
const dispatch = useDispatch();
49-
53+
const locationPath = useLocationPath();
5054
const [openStackIds, setOpenStackIds] = useState<TId[]>([]);
5155
const [filteredStacks, setFilteredStacks] = useState<TStack[]>([]);
5256

@@ -71,6 +75,23 @@ export const useService = (
7175
setFilteredStacks(orderedStacks);
7276
}, [stackComponents, filter]);
7377

78+
useEffect(() => {
79+
if (activeSorting === null) {
80+
// debugger;
81+
const intervalId = setInterval(() => {
82+
//assign interval to a variable to clear it.
83+
dispatch(
84+
stackComponentsActions.getMy({
85+
// id: currentWorkspace.id,
86+
type: locationPath.split('/')[2],
87+
}),
88+
);
89+
}, 5000);
90+
91+
return () => clearInterval(intervalId);
92+
}
93+
});
94+
7495
const setSelectedRunIds = (runIds: TId[]) => {
7596
dispatch(stackPagesActions.setSelectedRunIds({ runIds }));
7697
};

src/ui/layouts/stackComponents/Stacks/useService.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ export const useService = (): ServiceInterface => {
4747
);
4848
}, [locationPath]);
4949

50-
useEffect(() => {
51-
const intervalId = setInterval(() => {
52-
//assign interval to a variable to clear it.
53-
dispatch(
54-
stackComponentsActions.getMy({
55-
// id: currentWorkspace.id,
56-
type: locationPath.split('/')[2],
57-
onSuccess: () => setFetching(false),
58-
onFailure: () => setFetching(false),
59-
}),
60-
);
61-
}, 5000);
62-
63-
return () => clearInterval(intervalId);
64-
});
65-
6650
const setFetching = (fetching: boolean) => {
6751
dispatch(stackPagesActions.setFetching({ fetching }));
6852
};

src/ui/layouts/stacks/Stacks/List/useService.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import _ from 'lodash';
44
import React from 'react';
55
import { useEffect, useState } from 'react';
66
import { useDispatch, useSelector } from 'react-redux';
7-
import { stackPagesActions } from '../../../../../redux/actions';
7+
import { stackPagesActions, stacksActions } from '../../../../../redux/actions';
88
import {
99
stackPagesSelectors,
1010
stackSelectors,
@@ -38,7 +38,7 @@ export const useService = (
3838
}[],
3939
): ServiceInterface => {
4040
const [activeSorting, setActiveSorting] = React.useState<Sorting | null>(
41-
'createdAt',
41+
null,
4242
);
4343
const [
4444
activeSortingDirection,
@@ -68,6 +68,18 @@ export const useService = (
6868
setFilteredStacks(orderedStacks);
6969
}, [Stacks, filter]);
7070

71+
useEffect(() => {
72+
if (activeSorting === null) {
73+
const intervalId = setInterval(() => {
74+
//assign interval to a variable to clear it.
75+
dispatch(stacksActions.getMy({}));
76+
}, 5000);
77+
78+
return () => clearInterval(intervalId);
79+
}
80+
//This is important
81+
});
82+
7183
const setSelectedRunIds = (runIds: TId[]) => {
7284
dispatch(stackPagesActions.setSelectedRunIds({ runIds }));
7385
};

src/ui/layouts/stacks/Stacks/useService.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ export const useService = (): ServiceInterface => {
4444
);
4545
}, [locationPath]);
4646

47-
useEffect(() => {
48-
const intervalId = setInterval(() => {
49-
//assign interval to a variable to clear it.
50-
dispatch(
51-
stacksActions.getMy({
52-
onSuccess: () => setFetching(false),
53-
onFailure: () => setFetching(false),
54-
}),
55-
);
56-
}, 5000);
47+
// useEffect(() => {
48+
// const intervalId = setInterval(() => {
49+
// //assign interval to a variable to clear it.
50+
// dispatch(
51+
// stacksActions.getMy({
52+
// onSuccess: () => setFetching(false),
53+
// onFailure: () => setFetching(false),
54+
// }),
55+
// );
56+
// }, 5000);
5757

58-
return () => clearInterval(intervalId); //This is important
59-
});
58+
// return () => clearInterval(intervalId); //This is important
59+
// });
6060

6161
const setFetching = (fetching: boolean) => {
6262
dispatch(stackPagesActions.setFetching({ fetching }));

0 commit comments

Comments
 (0)