Skip to content

Commit 15531cf

Browse files
authored
Merge pull request #3953 from sumitdaga/issue-3948
fix for issue #3948
2 parents 4ebc4ab + 3dcc2db commit 15531cf

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
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 & 11 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,12 +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: {},
52+
projectNonDirty: getEmptyProjectObject(),
5053
updateExisting: false,
5154
phases: null,
5255
phasesNonDirty: null,
@@ -188,8 +191,8 @@ export const projectState = function (state=initialState, action) {
188191
case LOAD_PROJECT_PENDING:
189192
return Object.assign({}, state, {
190193
isLoading: true,
191-
project: null,
192-
projectNonDirty: null
194+
project: getEmptyProjectObject(),
195+
projectNonDirty: getEmptyProjectObject(),
193196
})
194197

195198
case LOAD_PROJECT_SUCCESS:
@@ -352,8 +355,8 @@ export const projectState = function (state=initialState, action) {
352355
case GET_PROJECTS_SUCCESS:
353356
return Object.assign({}, state, {
354357
isLoading: true, // this is excpected to be default value when there is not project loaded
355-
project: {},
356-
projectNonDirty: {},
358+
project: getEmptyProjectObject(),
359+
projectNonDirty: getEmptyProjectObject(),
357360
phases: null,
358361
phasesNonDirty: null,
359362
})
@@ -523,8 +526,8 @@ export const projectState = function (state=initialState, action) {
523526
return Object.assign({}, state, {
524527
processing: false,
525528
error: false,
526-
project: {},
527-
projectNonDirty: {}
529+
project: getEmptyProjectObject(),
530+
projectNonDirty: getEmptyProjectObject(),
528531
})
529532

530533
// Project attachments

0 commit comments

Comments
 (0)