Remove unused code

This commit is contained in:
Dane Everitt 2020-07-10 23:09:37 -07:00
parent fa9800fa88
commit 6188b9287c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 1 additions and 40 deletions

View file

@ -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<ServerFileStore, string, Record<string, unknown>, ServerStore, Promise<void>>;
setContents: Action<ServerFileStore, FileObject[]>;
pushFile: Action<ServerFileStore, FileObject>;
removeFile: Action<ServerFileStore, string>;
setDirectory: Action<ServerFileStore, string>;
}
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);

View file

@ -77,7 +77,6 @@ export const ServerContext = createContextStore<ServerStore>({
state.databases.data = [];
state.subusers.data = [];
state.files.directory = '/';
state.files.contents = [];
state.backups.data = [];
state.schedules.data = [];