Merge branch 'develop' into v2
This commit is contained in:
commit
e384c0d5c3
9 changed files with 43 additions and 63 deletions
|
@ -1,16 +1,16 @@
|
|||
import useWebsocketEvent from '@/plugins/useWebsocketEvent';
|
||||
import { ServerContext } from '@/state/server';
|
||||
import { SocketEvent } from '@/components/server/events';
|
||||
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
|
||||
import { mutate } from 'swr';
|
||||
import { getDirectorySwrKey } from '@/plugins/useFileManagerSwr';
|
||||
|
||||
const InstallListener = () => {
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const getServer = ServerContext.useStoreActions(actions => actions.server.getServer);
|
||||
const { mutate } = useFileManagerSwr();
|
||||
const setServerFromState = ServerContext.useStoreActions(actions => actions.server.setServerFromState);
|
||||
|
||||
useWebsocketEvent(SocketEvent.BACKUP_RESTORE_COMPLETED, async () => {
|
||||
await mutate(undefined);
|
||||
await mutate(getDirectorySwrKey(uuid, '/'), undefined);
|
||||
setServerFromState(s => ({ ...s, status: null }));
|
||||
});
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ export type SettableModalProps = Omit<ModalProps, 'appear' | 'visible' | 'onDism
|
|||
interface State {
|
||||
render: boolean;
|
||||
visible: boolean;
|
||||
showSpinnerOverlay?: boolean;
|
||||
propOverrides: Partial<SettableModalProps>;
|
||||
}
|
||||
|
||||
|
@ -31,7 +30,6 @@ function asModal<P extends {}> (modalProps?: SettableModalProps | ((props: P) =>
|
|||
this.state = {
|
||||
render: props.visible,
|
||||
visible: props.visible,
|
||||
showSpinnerOverlay: undefined,
|
||||
propOverrides: {},
|
||||
};
|
||||
}
|
||||
|
@ -39,7 +37,6 @@ function asModal<P extends {}> (modalProps?: SettableModalProps | ((props: P) =>
|
|||
get computedModalProps (): Readonly<SettableModalProps & { visible: boolean }> {
|
||||
return {
|
||||
...(typeof modalProps === 'function' ? modalProps(this.props) : modalProps),
|
||||
showSpinnerOverlay: this.state.showSpinnerOverlay,
|
||||
...this.state.propOverrides,
|
||||
visible: this.state.visible,
|
||||
};
|
||||
|
@ -50,7 +47,7 @@ function asModal<P extends {}> (modalProps?: SettableModalProps | ((props: P) =>
|
|||
*/
|
||||
componentDidUpdate (prevProps: Readonly<P & AsModalProps>, prevState: Readonly<State>) {
|
||||
if (prevProps.visible && !this.props.visible) {
|
||||
this.setState({ visible: false, showSpinnerOverlay: false });
|
||||
this.setState({ visible: false, propOverrides: {} });
|
||||
} else if (!prevProps.visible && this.props.visible) {
|
||||
this.setState({ render: true, visible: true });
|
||||
}
|
||||
|
|
|
@ -3,12 +3,14 @@ import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory';
|
|||
import { cleanDirectoryPath } from '@/helpers';
|
||||
import { ServerContext } from '@/state/server';
|
||||
|
||||
export const getDirectorySwrKey = (uuid: string, directory: string): string => `${uuid}:files:${directory}`;
|
||||
|
||||
export default () => {
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const directory = ServerContext.useStoreState(state => state.files.directory);
|
||||
|
||||
return useSWR<FileObject[]>(
|
||||
`${uuid}:files:${directory}`,
|
||||
getDirectorySwrKey(uuid, directory),
|
||||
() => loadDirectory(uuid, cleanDirectoryPath(directory)),
|
||||
{
|
||||
focusThrottleInterval: 30000,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue