Skip to content

Commit c21b228

Browse files
author
Adriána Kohanová
committed
#469 Make ideas/actions pretty and recognisable
1 parent 48e5071 commit c21b228

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

js/reducers/tracking/dispatchActions.js

+26-16
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,8 @@ const getTrackingActions = projectID => (dispatch, getState) => {
14551455
let listToSet = [];
14561456
results.forEach(r => {
14571457
let resultActions = JSON.parse(r.actions);
1458-
listToSet.push(...resultActions);
1458+
let actions = resultActions.map(obj => ({ ...obj, actionId: r.id }));
1459+
listToSet.push(...actions);
14591460
});
14601461

14611462
let projectActions = [...listToSet, ...sendActions];
@@ -1534,23 +1535,32 @@ export const updateTrackingActions = action => (dispatch, getState) => {
15341535
const project = state.projectReducers.currentProject;
15351536
const projectActions = state.trackingReducers.project_actions_list;
15361537
const projectID = project && project.projectID;
1537-
const actionID = action && action.Id;
1538+
let actionID = action && action.actionId;
15381539

1539-
if (projectID && actionID) {
1540-
const dataToSend = {
1541-
last_update_date: moment().format(),
1542-
actions: JSON.stringify(projectActions)
1543-
};
1544-
return api({
1545-
url: `${base_url}/api/session-actions/${projectID}/${actionID}`,
1546-
method: METHOD.PUT,
1547-
data: JSON.stringify(dataToSend)
1548-
})
1549-
.then(() => {})
1550-
.catch(error => {
1551-
throw new Error(error);
1540+
if (projectID && actionID && projectActions) {
1541+
let actions = projectActions.filter(a => a.actionId === actionID);
1542+
1543+
if (actions && actions.length > 0) {
1544+
const dataToSend = {
1545+
session_action_id: actionID,
1546+
session_project: projectID,
1547+
author: project.authorID,
1548+
last_update_date: moment().format(),
1549+
actions: JSON.stringify(actions)
1550+
};
1551+
return api({
1552+
url: `${base_url}/api/session-actions/${actionID}`,
1553+
method: METHOD.PUT,
1554+
data: JSON.stringify(dataToSend)
15521555
})
1553-
.finally(() => {});
1556+
.then(() => {})
1557+
.catch(error => {
1558+
throw new Error(error);
1559+
})
1560+
.finally(() => {});
1561+
} else {
1562+
return Promise.resolve();
1563+
}
15541564
} else {
15551565
return Promise.resolve();
15561566
}

0 commit comments

Comments
 (0)