Skip to content

Commit 840cf62

Browse files
data loading with reinitialization
1 parent a0293f2 commit 840cf62

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/app/clientApp/Devices/List/DevicesListPage/Tabs/Tab1.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import AppContext from '../../../../../share/AppContext'
2323
import { messages as app } from '../../../../App/App.i18n'
2424
import { useDevicesListCache } from '../../../hooks'
2525
import { getApiErrorMessage } from '../../../../../../common/utils'
26+
import { getWellKnowConfig } from '../../../../utils'
2627

2728
const { OWNED, UNSUPPORTED } = devicesOwnerships
2829

@@ -40,10 +41,18 @@ const Tab1 = forwardRef<Tab1RefType, Props>((props, ref) => {
4041
useDevicesList: useDevicesListProp,
4142
} = { ...defaultProps, ...props }
4243
const { formatMessage: _ } = useIntl()
44+
const wellKnownConfig = getWellKnowConfig()
4345
const [deleteModalOpen, setDeleteModalOpen] = useState(false)
4446
const [selectedDevices, setSelectedDevices] = useState([])
4547
const [isAllSelected, setIsAllSelected] = useState(false)
46-
const { data, loading: loadingData, error: deviceError, refresh, discovery, setState } = useDevicesListCache(useDevicesListProp)
48+
const {
49+
data,
50+
loading: loadingData,
51+
error: deviceError,
52+
refresh,
53+
discovery,
54+
setState,
55+
} = useDevicesListCache(useDevicesListProp && wellKnownConfig.isInitialized)
4756
const [singleDevice, setSingleDevice] = useState<null | string>(null)
4857

4958
const dispatch = useDispatch()
@@ -58,13 +67,6 @@ const Tab1 = forwardRef<Tab1RefType, Props>((props, ref) => {
5867
},
5968
}))
6069

61-
useEffect(() => {
62-
if (isActiveTab) {
63-
!loadingData && refresh()
64-
}
65-
// eslint-disable-next-line react-hooks/exhaustive-deps
66-
}, [isActiveTab])
67-
6870
useEffect(() => {
6971
setLoading(loadingData)
7072
}, [loadingData])

src/app/clientApp/Devices/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const useDevicesListCache = (requestActive: boolean): UseDevicesListCache
111111
}
112112
})()
113113
},
114-
[refreshIndex] // eslint-disable-line
114+
[refreshIndex, requestActive] // eslint-disable-line
115115
)
116116

117117
return {

0 commit comments

Comments
 (0)