mirror of
https://github.com/cloudreve/frontend.git
synced 2025-12-25 19:52:48 +00:00
fix(uploader): prevent drag upload hint from showing in trash directory (cloudreve/cloudreve#2229)
This commit is contained in:
parent
9d7649aa2a
commit
9a1a56e1a3
|
|
@ -1,6 +1,6 @@
|
|||
import dayjs from "dayjs";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { closeUploadTaskList, openUploadTaskList, setUploadProgress } from "../../redux/globalStateSlice.ts";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks.ts";
|
||||
|
|
@ -12,6 +12,7 @@ import Base, { Status } from "./core/uploader/base.ts";
|
|||
import { DropFileBackground } from "./DropFile.tsx";
|
||||
import PasteUploadDialog from "./PasteUploadDialog.tsx";
|
||||
import TaskList from "./Popup/TaskList.tsx";
|
||||
import { defaultTrashPath } from "../../hooks/useNavigation.tsx";
|
||||
|
||||
let totalProgressCollector: NodeJS.Timeout | null = null;
|
||||
let lastProgressStart = -1;
|
||||
|
|
@ -25,6 +26,8 @@ const Uploader = () => {
|
|||
const { enqueueSnackbar } = useSnackbar();
|
||||
const [uploaders, setUploaders] = useState<Base[]>([]);
|
||||
const [dropBgOpen, setDropBgOpen] = useState(false);
|
||||
|
||||
const pathRef = useRef<string>();
|
||||
|
||||
const totalProgress = useAppSelector((state) => state.globalState.uploadProgress);
|
||||
const taskListOpen = useAppSelector((state) => state.globalState.uploadTaskListOpen);
|
||||
|
|
@ -34,6 +37,9 @@ const Uploader = () => {
|
|||
const selectFileSignal = useAppSelector((state) => state.globalState.uploadFileSignal);
|
||||
const selectFolderSignal = useAppSelector((state) => state.globalState.uploadFolderSignal);
|
||||
|
||||
// Update path
|
||||
pathRef.current = path;
|
||||
|
||||
const taskAdded = useCallback(
|
||||
(original?: Base) => (tasks: Base[]) => {
|
||||
if (original !== undefined) {
|
||||
|
|
@ -69,10 +75,16 @@ const Uploader = () => {
|
|||
enqueueSnackbar(msg, { variant: type });
|
||||
},
|
||||
onDropOver: (_e) => {
|
||||
if (pathRef.current === defaultTrashPath) {
|
||||
return;
|
||||
}
|
||||
dragCounter++;
|
||||
setDropBgOpen((value) => !value);
|
||||
},
|
||||
onDropLeave: (_e) => {
|
||||
if (pathRef.current === defaultTrashPath) {
|
||||
return;
|
||||
}
|
||||
dragCounter--;
|
||||
setDropBgOpen((value) => !value);
|
||||
},
|
||||
|
|
@ -84,11 +96,11 @@ const Uploader = () => {
|
|||
}, 1000);
|
||||
},
|
||||
});
|
||||
}, []);
|
||||
}, [enqueueSnackbar, taskAdded, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
uploadManager.setPolicy(policy, path);
|
||||
}, [policy]);
|
||||
}, [policy, path]);
|
||||
|
||||
const handleUploaderError = useCallback(
|
||||
(e: any) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue