import { action, Action } from 'easy-peasy'; import { cleanDirectoryPath } from '@/helpers'; export interface ServerFileStore { directory: string; selectedFiles: string[]; setDirectory: Action; setSelectedFiles: Action; appendSelectedFile: Action; removeSelectedFile: Action; } const files: ServerFileStore = { directory: '/', selectedFiles: [], setDirectory: action((state, payload) => { state.directory = cleanDirectoryPath(payload); }), setSelectedFiles: action((state, payload) => { state.selectedFiles = payload; }), appendSelectedFile: action((state, payload) => { state.selectedFiles = state.selectedFiles.filter(f => f !== payload).concat(payload); }), removeSelectedFile: action((state, payload) => { state.selectedFiles = state.selectedFiles.filter(f => f !== payload); }), }; export default files;