diff --git a/resources/scripts/state/server/files.ts b/resources/scripts/state/server/files.ts index 7944d8c3d..d6f137b28 100644 --- a/resources/scripts/state/server/files.ts +++ b/resources/scripts/state/server/files.ts @@ -1,51 +1,13 @@ -import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory'; -import { action, Action, thunk, Thunk } from 'easy-peasy'; -import { ServerStore } from '@/state/server/index'; +import { action, Action } from 'easy-peasy'; import { cleanDirectoryPath } from '@/helpers'; export interface ServerFileStore { directory: string; - contents: FileObject[]; - getDirectoryContents: Thunk, ServerStore, Promise>; - setContents: Action; - pushFile: Action; - removeFile: Action; setDirectory: Action; } const files: ServerFileStore = { directory: '/', - contents: [], - - getDirectoryContents: thunk(async (actions, payload, { getStoreState }) => { - const server = getStoreState().server.data; - if (!server) { - return; - } - - const contents = await loadDirectory(server.uuid, cleanDirectoryPath(payload)); - - actions.setDirectory(payload.length === 0 ? '/' : payload); - actions.setContents(contents); - }), - - setContents: action((state, payload) => { - state.contents = payload; - }), - - pushFile: action((state, payload) => { - const matchIndex = state.contents.findIndex(file => file.uuid === payload.uuid); - if (matchIndex < 0) { - state.contents = state.contents.concat(payload); - return; - } - - state.contents[matchIndex] = payload; - }), - - removeFile: action((state, payload) => { - state.contents = state.contents.filter(file => file.uuid !== payload); - }), setDirectory: action((state, payload) => { state.directory = cleanDirectoryPath(payload); diff --git a/resources/scripts/state/server/index.ts b/resources/scripts/state/server/index.ts index f0d3c66db..cecb01acb 100644 --- a/resources/scripts/state/server/index.ts +++ b/resources/scripts/state/server/index.ts @@ -77,7 +77,6 @@ export const ServerContext = createContextStore({ state.databases.data = []; state.subusers.data = []; state.files.directory = '/'; - state.files.contents = []; state.backups.data = []; state.schedules.data = [];