Skip to content

Commit e7ef51a

Browse files
authored
Merge pull request #4238 from yoution/feature/issue-4236
fix: #4236
2 parents cb399af + bb8002b commit e7ef51a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/projects/list/components/Projects/Projects.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,7 @@ class Projects extends Component {
335335
}
336336
}
337337

338-
const mapStateToProps = ({ projectSearch, members, loadUser, projectState, templates, notifications }) => {
339-
if (projectState.project && projectState.project.id && projectSearch.projects) {
340-
const index = _.findIndex(projectSearch.projects, {id: projectState.project.id})
341-
projectSearch.projects.splice(index, 1, projectState.project)
342-
}
338+
const mapStateToProps = ({ projectSearch, members, loadUser, templates, notifications }) => {
343339
const defaultListView = hasPermission(PERMISSIONS.SEE_GRID_VIEW_BY_DEFAULT) ? PROJECTS_LIST_VIEW.GRID : PROJECTS_LIST_VIEW.CARD
344340
return {
345341
currentUser : {

src/projects/reducers/projectSearch.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
SET_PROJECTS_LIST_VIEW,
77
PROJECT_LIST_DEFAULT_CRITERIA,
88
PROJECT_SORT,
9+
UPDATE_PROJECT_SUCCESS,
910
DELETE_PROJECT_SUCCESS,
1011
ACCEPT_OR_REFUSE_INVITE_SUCCESS,
1112
ADMIN_ROLES,
@@ -157,6 +158,20 @@ export default function(state = initialState, action) {
157158
projectsListView: action.payload
158159
})
159160

161+
case UPDATE_PROJECT_SUCCESS: {
162+
const { projects } = state
163+
const projectIndex = _.findIndex(projects, {id: action.payload.id})
164+
const oldProject = projects[projectIndex]
165+
const newProject = {
166+
...action.payload,
167+
attachments: _.get(oldProject, 'attachments', []),
168+
members: _.get(oldProject, 'members', []),
169+
invites: _.get(oldProject, 'invites', []),
170+
}
171+
return update(state, {
172+
projects: { $splice: [[projectIndex, 1, newProject]] }
173+
})
174+
}
160175
case DELETE_PROJECT_SUCCESS: {
161176
return Object.assign({}, state, {
162177
refresh: true

0 commit comments

Comments
 (0)