diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index 0bd7e59..6680b07 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -4,19 +4,21 @@ import { Card, CardBody, Center, + Collapse, Grid, GridItem, Image, Link, Text, + useDisclosure, VStack, Wrap, WrapItem, } from '@chakra-ui/react'; -import { DecryptedAudioFile, ProcessState, deleteFile } from './fileListingSlice'; -import { useRef } from 'react'; +import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; +import { useCallback, useRef } from 'react'; import { useAppDispatch } from '~/hooks'; -import coverFallback from '~/assets/no-cover.svg'; +import coverSvgUrl from '~/assets/no-cover.svg'; interface FileRowProps { id: string; @@ -24,6 +26,7 @@ interface FileRowProps { } export function FileRow({ id, file }: FileRowProps) { + const { isOpen, onClose } = useDisclosure({ defaultIsOpen: true }); const dispatch = useAppDispatch(); const isDecrypted = file.state === ProcessState.COMPLETE; const metadata = file.metadata; @@ -45,97 +48,100 @@ export function FileRow({ id, file }: FileRowProps) { } }; - const handleDeleteRow = () => { - dispatch(deleteFile({ id })); - }; + const handleDeleteRow = useCallback(() => { + onClose(); + setTimeout(() => { + dispatch(deleteFile({ id })); + }, 500); + }, [dispatch, id, onClose]); return ( - - - + + + - -
- {metadata && ( + }} + gridTemplateRows={{ + base: 'repeat(auto-fill)', + md: 'min-content 1fr', + }} + gridTemplateColumns={{ + base: '1fr', + md: '160px 1fr', + }} + gap="1" + > + +
{`"${metadata.album}" - )} -
-
- - - {metadata?.name ?? nameWithoutExt} - - - - {isDecrypted && metadata && ( - - - 专辑: {metadata.album} - - - 艺术家: {metadata.artist} - - - 专辑艺术家: {metadata.albumArtist} - +
+
+ + + {metadata?.name ?? nameWithoutExt} - )} - - - - {file.decrypted && + + {isDecrypted && metadata && ( + + + 专辑: {metadata.album} + + + 艺术家: {metadata.artist} + + + 专辑艺术家: {metadata.albumArtist} + + + )} + + + + {file.decrypted && - -
-
-
+ + + +
+
+
+ ); }