Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix automatic camel casing of subscriber attribs on the UI.

Kailash Nadhf1fbcd473e4d
diff --git a/frontend/src/api/index.js b/frontend/src/api/index.js
index 031f8c69..7b346f2c 100644
--- a/frontend/src/api/index.js
+++ b/frontend/src/api/index.js
@@ -39,6 +39,23 @@ http.interceptors.response.use((resp) => {
// Transform field case.
data = humps.camelizeKeys(resp.data.data);
}
+
+ if (resp.config.preserveCase && resp.config.preserveResultsCase) {
+ resp.data.data.results.forEach((r, n) => {
+ // Only preserve case for certain keys under the 'results' key.
+ const save = {};
+ resp.config.preserveResultsCase.forEach((key) => {
+ save[key] = JSON.stringify(r[key]);
+ });
+
+ const item = humps.camelizeKeys(r);
+ Object.keys(save).forEach((key) => {
+ item[key] = JSON.parse(save[key]);
+ });
+
+ data.results[n] = item;
+ });
+ }
} else {
data = resp.data.data;
}
@@ -111,7 +128,13 @@ export const deleteList = (id) => http.delete(`/api/lists/${id}`,
// Subscribers.
export const getSubscribers = async (params) => http.get('/api/subscribers',
- { params, loading: models.subscribers, store: models.subscribers });
+ {
+ params,
+ loading: models.subscribers,
+ store: models.subscribers,
+ preserveCase: true,
+ preserveResultsCase: ['attribs'],
+ });
export const getSubscriber = async (id) => http.get(`/api/subscribers/${id}`,
{ loading: models.subscribers });