@@ -29,6 +29,10 @@ import _ from 'lodash'
2929import update from 'react-addons-update'
3030import { clean } from '../../helpers/utils'
3131
32+ export function getEmptyProjectObject ( ) {
33+ return { invites : [ ] , members : [ ] }
34+ }
35+
3236const 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