aboutsummaryrefslogtreecommitdiff
path: root/modern/src/CachingController.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/CachingController.js')
-rw-r--r--modern/src/CachingController.js65
1 files changed, 64 insertions, 1 deletions
diff --git a/modern/src/CachingController.js b/modern/src/CachingController.js
index fa3b9f6b..faeec482 100644
--- a/modern/src/CachingController.js
+++ b/modern/src/CachingController.js
@@ -1,6 +1,6 @@
import { useDispatch, useSelector } from 'react-redux';
import { connect } from 'react-redux';
-import { geofencesActions } from './store';
+import { geofencesActions, groupsActions, driversActions, calendarsActions, commandsActions, computedAttributesActions, maintenancesActions, notificationsActions } from './store';
import { useEffectAsync } from './reactHelper';
const CachingController = () => {
@@ -15,6 +15,69 @@ const CachingController = () => {
}
}
}, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/groups');
+ if (response.ok) {
+ dispatch(groupsActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/drivers');
+ if (response.ok) {
+ dispatch(driversActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/calendars');
+ if (response.ok) {
+ dispatch(calendarsActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/commands');
+ if (response.ok) {
+ dispatch(commandsActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/attributes/computed');
+ if (response.ok) {
+ dispatch(computedAttributesActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/maintenance');
+ if (response.ok) {
+ dispatch(maintenancesActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
+
+ useEffectAsync(async () => {
+ if (authenticated) {
+ const response = await fetch('/api/notifications');
+ if (response.ok) {
+ dispatch(notificationsActions.update(await response.json()));
+ }
+ }
+ }, [authenticated]);
return null;
}