Remove unused code
This commit is contained in:
parent
fa9800fa88
commit
6188b9287c
2 changed files with 1 additions and 40 deletions
|
@ -1,51 +1,13 @@
|
||||||
import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory';
|
import { action, Action } from 'easy-peasy';
|
||||||
import { action, Action, thunk, Thunk } from 'easy-peasy';
|
|
||||||
import { ServerStore } from '@/state/server/index';
|
|
||||||
import { cleanDirectoryPath } from '@/helpers';
|
import { cleanDirectoryPath } from '@/helpers';
|
||||||
|
|
||||||
export interface ServerFileStore {
|
export interface ServerFileStore {
|
||||||
directory: string;
|
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>;
|
setDirectory: Action<ServerFileStore, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const files: ServerFileStore = {
|
const files: ServerFileStore = {
|
||||||
directory: '/',
|
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) => {
|
setDirectory: action((state, payload) => {
|
||||||
state.directory = cleanDirectoryPath(payload);
|
state.directory = cleanDirectoryPath(payload);
|
||||||
|
|
|
@ -77,7 +77,6 @@ export const ServerContext = createContextStore<ServerStore>({
|
||||||
state.databases.data = [];
|
state.databases.data = [];
|
||||||
state.subusers.data = [];
|
state.subusers.data = [];
|
||||||
state.files.directory = '/';
|
state.files.directory = '/';
|
||||||
state.files.contents = [];
|
|
||||||
state.backups.data = [];
|
state.backups.data = [];
|
||||||
state.schedules.data = [];
|
state.schedules.data = [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue