import { Dispatch } from 'redux' ; import { SelectFolderResult } from '../../common/Types' ; import { Folder , ActionType } from '../RendererTypes' ; returns export const requestRegisterRootFolder = ( ) => ( { type : ActionType . RequestRegisterRootFolder as ActionType . RequestRegisterRootFolder } ) ; param folder returns export const finishRegisterRootFolder = ( folder ? ) => ( { type : ActionType . FinishRegisterRootFolder as ActionType . FinishRegisterRootFolder , payload : { folder } } ) ; /**
 * Add a folder to the root of the folder tree.
 */ export const registerRootFolder = ( ) => async ( dispatch ) => { dispatch ( requestRegisterRootFolder ( ) ) ; const result = await window . myAPI . selectFolder ( ) ; if ( ! result ) { return dispatch ( finishRegisterRootFolder ( ) ) ; } const folder = { treeId : 0 , isRoot : true , name : result . name , path : result . folderPath , subFolders : result . items . filter ( ( item ) => item . isDirectory ) . map ( ( item ) : Folder => ( { treeId : 0 , isRoot : false , name : item . name , path : item . path , subFolders : [ ] } ) ) } ; dispatch ( finishRegisterRootFolder ( folder ) ) ; } ;