Don't execute unnecessary HTTP requests when browing a file directory

This commit is contained in:
Dane Everitt 2020-04-10 13:57:24 -07:00
parent 76300209f1
commit b72a770ec9
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 17 additions and 19 deletions

View file

@ -1,6 +1,7 @@
import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory';
import { action, Action, thunk, Thunk } from 'easy-peasy';
import { ServerStore } from '@/state/server/index';
import { cleanDirectoryPath } from '@/helpers';
export interface ServerFileStore {
directory: string;
@ -22,7 +23,7 @@ const files: ServerFileStore = {
return;
}
const contents = await loadDirectory(server.uuid, payload);
const contents = await loadDirectory(server.uuid, cleanDirectoryPath(payload));
actions.setDirectory(payload.length === 0 ? '/' : payload);
actions.setContents(contents);
@ -47,7 +48,7 @@ const files: ServerFileStore = {
}),
setDirectory: action((state, payload) => {
state.directory = payload.length === 0 ? '/' : payload;
state.directory = cleanDirectoryPath(payload)
}),
};