@@ -158,10 +158,28 @@ const files = (state, action) => {
158158 }
159159 return Object . assign ( { } , file , { blobURL : action . blobURL } ) ;
160160 } ) ;
161- case ActionTypes . NEW_PROJECT :
162- return setFilePaths ( action . files ) ;
163- case ActionTypes . SET_PROJECT :
164- return setFilePaths ( action . files ) ;
161+ case ActionTypes . NEW_PROJECT : {
162+ const newFiles = action . files . map ( ( file ) => {
163+ const corrospondingObj = state . find ( ( obj ) => obj . id === file . id ) ;
164+ if ( corrospondingObj && corrospondingObj . fileType === 'folder' ) {
165+ const isFolderClosed = corrospondingObj . isFolderClosed || false ;
166+ return { ...file , isFolderClosed } ;
167+ }
168+ return file ;
169+ } ) ;
170+ return setFilePaths ( newFiles ) ;
171+ }
172+ case ActionTypes . SET_PROJECT : {
173+ const newFiles = action . files . map ( ( file ) => {
174+ const corrospondingObj = state . find ( ( obj ) => obj . id === file . id ) ;
175+ if ( corrospondingObj && corrospondingObj . fileType === 'folder' ) {
176+ const isFolderClosed = corrospondingObj . isFolderClosed || false ;
177+ return { ...file , isFolderClosed } ;
178+ }
179+ return file ;
180+ } ) ;
181+ return setFilePaths ( newFiles ) ;
182+ }
165183 case ActionTypes . RESET_PROJECT :
166184 return initialState ( ) ;
167185 case ActionTypes . CREATE_FILE : {
@@ -188,6 +206,7 @@ const files = (state, action) => {
188206 filePath
189207 }
190208 ] ;
209+
191210 return newState . map ( ( file ) => {
192211 if ( file . id === action . parentId ) {
193212 file . children = sortedChildrenId ( newState , file . children ) ;
0 commit comments