@@ -229,20 +229,24 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
229229 this . args . setPageDirty ( ) ;
230230 }
231231 this . isNextButtonDisabled = true ;
232- if ( this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . titleAndAbstract ) &&
232+
233+ if (
234+ this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . titleAndAbstract ) &&
233235 this . titleAndAbstractValidation
234236 ) {
235237 await this . saveOnStep ( ) ;
236238 await this . preprint . files ;
237- this . isNextButtonDisabled = ! this . metadataValidation ;
239+ this . isNextButtonDisabled = ! this . fileValidation ;
238240 return ;
239- } else if ( this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . file ) &&
241+ } else if (
242+ this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . file ) &&
240243 this . fileValidation
241244 ) {
242245 await this . saveOnStep ( ) ;
243- this . isNextButtonDisabled = ! this . authorAssertionValidation ;
246+ this . isNextButtonDisabled = ! this . metadataValidation ;
244247 return ;
245- } else if ( this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . metadata ) &&
248+ } else if (
249+ this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . metadata ) &&
246250 this . metadataValidation
247251 ) {
248252 await this . saveOnStep ( ) ;
@@ -252,13 +256,15 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
252256 this . isNextButtonDisabled = ! this . supplementValidation ;
253257 }
254258 return ;
255- } else if ( this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . authorAssertions ) &&
259+ } else if (
260+ this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . authorAssertions ) &&
256261 this . authorAssertionValidation
257262 ) {
258263 await this . saveOnStep ( ) ;
259264 this . isNextButtonDisabled = ! this . supplementValidation ;
260265 return ;
261- } else if ( this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . supplements ) &&
266+ } else if (
267+ this . statusFlowIndex === this . getTypeIndex ( PreprintStatusTypeEnum . supplements ) &&
262268 this . supplementValidation
263269 ) {
264270 await this . saveOnStep ( ) ;
@@ -607,10 +613,12 @@ export default class PreprintStateMachine extends Component<StateMachineArgs>{
607613 @task
608614 @waitFor
609615 public async addProjectFile ( file : FileModel ) : Promise < void > {
610- await file . copy ( this . preprint , '/' , 'osfstorage' ) ;
616+ await file . copy ( this . preprint , '/' , 'osfstorage' , {
617+ conflict : 'replace' ,
618+ } ) ;
611619 const theFiles = await this . preprint . files ;
612620 const rootFolder = await theFiles . firstObject ! . rootFolder ;
613621 const primaryFile = await rootFolder ! . files ;
614- this . preprint . set ( 'primaryFile' , primaryFile . firstObject ) ;
622+ this . preprint . set ( 'primaryFile' , primaryFile . lastObject ) ;
615623 }
616624}
0 commit comments