@@ -4,13 +4,17 @@ import _ from 'lodash';
44import React from 'react' ;
55import { useEffect , useState } from 'react' ;
66import { useDispatch , useSelector } from 'react-redux' ;
7- import { stackPagesActions } from '../../../../../redux/actions' ;
7+ import {
8+ stackComponentsActions ,
9+ stackPagesActions ,
10+ } from '../../../../../redux/actions' ;
811import {
912 stackComponentSelectors ,
1013 stackPagesSelectors ,
1114 stackSelectors ,
1215} from '../../../../../redux/selectors' ;
1316import { getFilteredDataForTable } from '../../../../../utils/tableFilters' ;
17+ import { useLocationPath } from '../../../../hooks' ;
1418import { Sorting , SortingDirection } from './ForSorting/types' ;
1519
1620interface 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 } ;
0 commit comments