feat: 删除歌曲行数据时改用 onClose 来处理

This commit is contained in:
HouKunLin 2023-05-17 09:10:36 +08:00
parent b8c3a51756
commit eaf05d8cbb

View File

@ -25,7 +25,7 @@ interface FileRowProps {
} }
export function FileRow({ id, file }: FileRowProps) { export function FileRow({ id, file }: FileRowProps) {
const { isOpen, onToggle } = useDisclosure({ defaultIsOpen: true }); const { isOpen, onClose } = useDisclosure({ defaultIsOpen: true });
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const isDecrypted = file.state === ProcessState.COMPLETE; const isDecrypted = file.state === ProcessState.COMPLETE;
@ -47,11 +47,11 @@ export function FileRow({ id, file }: FileRowProps) {
}, []); }, []);
const handleDeleteRow = useCallback(() => { const handleDeleteRow = useCallback(() => {
onToggle(); onClose();
setTimeout(() => { setTimeout(() => {
dispatch(deleteFile({ id })); dispatch(deleteFile({ id }));
}, 500); }, 500);
}, [dispatch, id, onToggle]); }, [dispatch, id, onClose]);
return ( return (
<Collapse in={isOpen} animateOpacity unmountOnExit startingHeight={0} style={{ width: '100%' }}> <Collapse in={isOpen} animateOpacity unmountOnExit startingHeight={0} style={{ width: '100%' }}>