aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-12-11 20:41:31 -0800
committerAnton Tananaev <anton@traccar.org>2023-12-11 20:41:31 -0800
commit7d607dbc8f2f5636dd1319ff018add3265c923aa (patch)
treeaca67555548e463126a01d1d73314ebd975ae151 /modern/src
parent3b38142f4ef581c76ec089d430cda86337609bc1 (diff)
downloadtrackermap-web-7d607dbc8f2f5636dd1319ff018add3265c923aa.tar.gz
trackermap-web-7d607dbc8f2f5636dd1319ff018add3265c923aa.tar.bz2
trackermap-web-7d607dbc8f2f5636dd1319ff018add3265c923aa.zip
Fix store refresh
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/CachingController.js10
-rw-r--r--modern/src/settings/CalendarPage.jsx2
-rw-r--r--modern/src/settings/GroupPage.jsx2
-rw-r--r--modern/src/store/calendars.js3
-rw-r--r--modern/src/store/drivers.js3
-rw-r--r--modern/src/store/groups.js3
-rw-r--r--modern/src/store/maintenances.js3
7 files changed, 15 insertions, 11 deletions
diff --git a/modern/src/CachingController.js b/modern/src/CachingController.js
index 55a4e020..b8e5fd90 100644
--- a/modern/src/CachingController.js
+++ b/modern/src/CachingController.js
@@ -13,7 +13,7 @@ const CachingController = () => {
if (authenticated) {
const response = await fetch('/api/geofences');
if (response.ok) {
- dispatch(geofencesActions.update(await response.json()));
+ dispatch(geofencesActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
@@ -24,7 +24,7 @@ const CachingController = () => {
if (authenticated) {
const response = await fetch('/api/groups');
if (response.ok) {
- dispatch(groupsActions.update(await response.json()));
+ dispatch(groupsActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
@@ -35,7 +35,7 @@ const CachingController = () => {
if (authenticated) {
const response = await fetch('/api/drivers');
if (response.ok) {
- dispatch(driversActions.update(await response.json()));
+ dispatch(driversActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
@@ -46,7 +46,7 @@ const CachingController = () => {
if (authenticated) {
const response = await fetch('/api/maintenance');
if (response.ok) {
- dispatch(maintenancesActions.update(await response.json()));
+ dispatch(maintenancesActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
@@ -57,7 +57,7 @@ const CachingController = () => {
if (authenticated) {
const response = await fetch('/api/calendars');
if (response.ok) {
- dispatch(calendarsActions.update(await response.json()));
+ dispatch(calendarsActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
diff --git a/modern/src/settings/CalendarPage.jsx b/modern/src/settings/CalendarPage.jsx
index 099858a3..b7dcdd04 100644
--- a/modern/src/settings/CalendarPage.jsx
+++ b/modern/src/settings/CalendarPage.jsx
@@ -99,7 +99,7 @@ const CalendarPage = () => {
const onItemSaved = useCatch(async () => {
const response = await fetch('/api/calendars');
if (response.ok) {
- dispatch(calendarsActions.update(await response.json()));
+ dispatch(calendarsActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
diff --git a/modern/src/settings/GroupPage.jsx b/modern/src/settings/GroupPage.jsx
index 51fbda0e..c4ca867d 100644
--- a/modern/src/settings/GroupPage.jsx
+++ b/modern/src/settings/GroupPage.jsx
@@ -39,7 +39,7 @@ const GroupPage = () => {
const onItemSaved = useCatch(async () => {
const response = await fetch('/api/groups');
if (response.ok) {
- dispatch(groupsActions.update(await response.json()));
+ dispatch(groupsActions.refresh(await response.json()));
} else {
throw Error(await response.text());
}
diff --git a/modern/src/store/calendars.js b/modern/src/store/calendars.js
index 924288e6..2d92c004 100644
--- a/modern/src/store/calendars.js
+++ b/modern/src/store/calendars.js
@@ -6,7 +6,8 @@ const { reducer, actions } = createSlice({
items: {},
},
reducers: {
- update(state, action) {
+ refresh(state, action) {
+ state.items = {};
action.payload.forEach((item) => state.items[item.id] = item);
},
},
diff --git a/modern/src/store/drivers.js b/modern/src/store/drivers.js
index 3ebbdd84..d62bd476 100644
--- a/modern/src/store/drivers.js
+++ b/modern/src/store/drivers.js
@@ -6,7 +6,8 @@ const { reducer, actions } = createSlice({
items: {},
},
reducers: {
- update(state, action) {
+ refresh(state, action) {
+ state.items = {};
action.payload.forEach((item) => state.items[item.uniqueId] = item);
},
},
diff --git a/modern/src/store/groups.js b/modern/src/store/groups.js
index 11fc5dbf..607b8609 100644
--- a/modern/src/store/groups.js
+++ b/modern/src/store/groups.js
@@ -6,7 +6,8 @@ const { reducer, actions } = createSlice({
items: {},
},
reducers: {
- update(state, action) {
+ refresh(state, action) {
+ state.items = {};
action.payload.forEach((item) => state.items[item.id] = item);
},
},
diff --git a/modern/src/store/maintenances.js b/modern/src/store/maintenances.js
index 08b2adb6..0f5e41d1 100644
--- a/modern/src/store/maintenances.js
+++ b/modern/src/store/maintenances.js
@@ -6,7 +6,8 @@ const { reducer, actions } = createSlice({
items: {},
},
reducers: {
- update(state, action) {
+ refresh(state, action) {
+ state.items = {};
action.payload.forEach((item) => state.items[item.id] = item);
},
},