Skip to content

Commit 3dcc2db

Browse files
committed
review fix
1 parent 51daf92 commit 3dcc2db

File tree

2 files changed

+16
-33
lines changed

2 files changed

+16
-33
lines changed

src/projects/detail/ProjectDetail.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { loadProjectDashboard } from '../actions/projectDashboard'
1010
import { clearLoadedProject } from '../actions/project'
1111
import { acceptOrRefuseInvite } from '../actions/projectMember'
1212
import { loadProjects } from '../actions/loadProjects'
13+
import { getEmptyProjectObject } from '../reducers/project'
1314

1415
import {
1516
LOAD_PROJECT_FAILURE, PROJECT_ROLE_CUSTOMER, PROJECT_ROLE_OWNER,
@@ -153,7 +154,7 @@ class ProjectDetail extends Component {
153154
componentWillReceiveProps(nextProps) {
154155
const {isProcessing, isLoading, error, project, match, showUserInvited} = nextProps
155156
// handle just deleted projects
156-
if (! (error || isLoading || isProcessing) && _.isEmpty(project))
157+
if (! (error || isLoading || isProcessing) && _.isEqual(getEmptyProjectObject(), project))
157158
this.props.history.push('/projects/')
158159
if (project && project.name) {
159160
document.title = `${project.name} - Topcoder`

src/projects/reducers/project.js

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ import _ from 'lodash'
2929
import update from 'react-addons-update'
3030
import { clean } from '../../helpers/utils'
3131

32+
export function getEmptyProjectObject() {
33+
return { invites: [], members: [] }
34+
}
35+
3236
const initialState = {
3337
isLoading: true,
3438
processing: false,
@@ -41,15 +45,11 @@ const initialState = {
4145
attachmentTags: null,
4246
error: false,
4347
inviteError: false,
44-
project: {
45-
members: [],
46-
invites: [] // invites are pushed directly into it hence need to declare first
47-
},
48+
// invites are pushed directly into it hence need to declare first
49+
// using the getEmptyProjectObject method
50+
project: getEmptyProjectObject(),
4851
assetsMembers: {},
49-
projectNonDirty: {
50-
members: [],
51-
invites: []
52-
},
52+
projectNonDirty: getEmptyProjectObject(),
5353
updateExisting: false,
5454
phases: null,
5555
phasesNonDirty: null,
@@ -191,14 +191,8 @@ export const projectState = function (state=initialState, action) {
191191
case LOAD_PROJECT_PENDING:
192192
return Object.assign({}, state, {
193193
isLoading: true,
194-
project: {
195-
members: [],
196-
invites: []
197-
},
198-
projectNonDirty: {
199-
members: [],
200-
invites: []
201-
},
194+
project: getEmptyProjectObject(),
195+
projectNonDirty: getEmptyProjectObject(),
202196
})
203197

204198
case LOAD_PROJECT_SUCCESS:
@@ -361,14 +355,8 @@ export const projectState = function (state=initialState, action) {
361355
case GET_PROJECTS_SUCCESS:
362356
return Object.assign({}, state, {
363357
isLoading: true, // this is excpected to be default value when there is not project loaded
364-
project: {
365-
members: [],
366-
invites: []
367-
},
368-
projectNonDirty: {
369-
members: [],
370-
invites: []
371-
},
358+
project: getEmptyProjectObject(),
359+
projectNonDirty: getEmptyProjectObject(),
372360
phases: null,
373361
phasesNonDirty: null,
374362
})
@@ -538,14 +526,8 @@ export const projectState = function (state=initialState, action) {
538526
return Object.assign({}, state, {
539527
processing: false,
540528
error: false,
541-
project: {
542-
members: [],
543-
invites: []
544-
},
545-
projectNonDirty: {
546-
members: [],
547-
invites: []
548-
},
529+
project: getEmptyProjectObject(),
530+
projectNonDirty: getEmptyProjectObject(),
549531
})
550532

551533
// Project attachments

0 commit comments

Comments
 (0)