Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/projects/detail/ProjectDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { loadProjectDashboard } from '../actions/projectDashboard'
import { clearLoadedProject } from '../actions/project'
import { acceptOrRefuseInvite } from '../actions/projectMember'
import { loadProjects } from '../actions/loadProjects'
import { getEmptyProjectObject } from '../reducers/project'

import {
LOAD_PROJECT_FAILURE, PROJECT_ROLE_CUSTOMER, PROJECT_ROLE_OWNER,
Expand Down Expand Up @@ -153,7 +154,7 @@ class ProjectDetail extends Component {
componentWillReceiveProps(nextProps) {
const {isProcessing, isLoading, error, project, match, showUserInvited} = nextProps
// handle just deleted projects
if (! (error || isLoading || isProcessing) && _.isEmpty(project))
if (! (error || isLoading || isProcessing) && _.isEqual(getEmptyProjectObject(), project))
this.props.history.push('/projects/')
if (project && project.name) {
document.title = `${project.name} - Topcoder`
Expand Down
25 changes: 14 additions & 11 deletions src/projects/reducers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import _ from 'lodash'
import update from 'react-addons-update'
import { clean } from '../../helpers/utils'

export function getEmptyProjectObject() {
return { invites: [], members: [] }
}

const initialState = {
isLoading: true,
processing: false,
Expand All @@ -41,12 +45,11 @@ const initialState = {
attachmentTags: null,
error: false,
inviteError: false,
project: {
members: [],
invites: [] // invites are pushed directly into it hence need to declare first
},
// invites are pushed directly into it hence need to declare first
// using the getEmptyProjectObject method
project: getEmptyProjectObject(),
assetsMembers: {},
projectNonDirty: {},
projectNonDirty: getEmptyProjectObject(),
updateExisting: false,
phases: null,
phasesNonDirty: null,
Expand Down Expand Up @@ -188,8 +191,8 @@ export const projectState = function (state=initialState, action) {
case LOAD_PROJECT_PENDING:
return Object.assign({}, state, {
isLoading: true,
project: null,
projectNonDirty: null
project: getEmptyProjectObject(),
projectNonDirty: getEmptyProjectObject(),
})

case LOAD_PROJECT_SUCCESS:
Expand Down Expand Up @@ -352,8 +355,8 @@ export const projectState = function (state=initialState, action) {
case GET_PROJECTS_SUCCESS:
return Object.assign({}, state, {
isLoading: true, // this is excpected to be default value when there is not project loaded
project: {},
projectNonDirty: {},
project: getEmptyProjectObject(),
projectNonDirty: getEmptyProjectObject(),
phases: null,
phasesNonDirty: null,
})
Expand Down Expand Up @@ -523,8 +526,8 @@ export const projectState = function (state=initialState, action) {
return Object.assign({}, state, {
processing: false,
error: false,
project: {},
projectNonDirty: {}
project: getEmptyProjectObject(),
projectNonDirty: getEmptyProjectObject(),
})

// Project attachments
Expand Down