mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
Don't execute unnecessary HTTP requests when browing a file directory
This commit is contained in:
@@ -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)
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user