Skip to content

Commit 13d5fa5

Browse files
committed
code cleanup
1 parent 426d677 commit 13d5fa5

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

netmanager/src/views/layouts/Main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const Main = (props) => {
9393
const fetchUserDetails = async () => {
9494
try {
9595
const res = await getUserDetails(JSON.parse(user)._id);
96-
if (res.success) {
96+
if (res.success && res.users && res.users.length > 0) {
9797
dispatch(addUserNetworks(res.users[0].networks));
9898
localStorage.setItem('userNetworks', JSON.stringify(res.users[0].networks));
9999
dispatch(addUserGroupSummary(res.users[0].groups));
@@ -103,7 +103,7 @@ const Main = (props) => {
103103
(network) => network.net_name === 'airqo'
104104
);
105105

106-
if (!activeNetwork) {
106+
if (!activeNetwork && airqoNetwork) {
107107
dispatch(addActiveNetwork(airqoNetwork));
108108
localStorage.setItem('activeNetwork', JSON.stringify(airqoNetwork));
109109
dispatch(addCurrentUserRole(airqoNetwork.role));

netmanager/src/views/pages/ExportData/index.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -270,21 +270,17 @@ const ExportData = (props) => {
270270
};
271271

272272
useEffect(() => {
273-
if (isEmpty(sites)) dispatch(loadSites());
273+
dispatch(loadSites());
274274
}, []);
275275

276276
useEffect(() => {
277-
if (isEmpty(deviceRegistrySites)) {
278-
if (!activeNetwork) return;
279-
dispatch(loadSitesData(activeNetwork.net_name));
280-
}
277+
if (!activeNetwork) return;
278+
dispatch(loadSitesData(activeNetwork.net_name));
281279
}, []);
282280

283281
useEffect(() => {
284-
if (isEmpty(deviceList)) {
285-
if (!activeNetwork) return;
286-
dispatch(loadDevicesData(activeNetwork.net_name));
287-
}
282+
if (!activeNetwork) return;
283+
dispatch(loadDevicesData(activeNetwork.net_name));
288284
}, []);
289285

290286
useEffect(() => {
@@ -300,9 +296,7 @@ const ExportData = (props) => {
300296
}, [deviceRegistrySites]);
301297

302298
useEffect(() => {
303-
if (isEmpty(airqlouds)) {
304-
dispatch(fetchDashboardAirQloudsData());
305-
}
299+
dispatch(fetchDashboardAirQloudsData());
306300
}, []);
307301

308302
useEffect(() => {
@@ -510,7 +504,7 @@ const ExportData = (props) => {
510504
sites: sitesList,
511505
device: getValues(selectedDevices),
512506
airqlouds: getValues(selectedAirqlouds),
513-
network: activeNetwork,
507+
network: activeNetwork.net_name,
514508
datatype: dataType.value,
515509
pollutants: getValues(pollutants),
516510
frequency: frequency.value,

0 commit comments

Comments
 (0)