From 4341203c08cf00504a78908b5195c99e04659698 Mon Sep 17 00:00:00 2001 From: HouKunLin Date: Wed, 17 May 2023 09:27:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20togglePlay=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BD=BF=E7=94=A8=20useCallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/file-listing/FileRow.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/features/file-listing/FileRow.tsx b/src/features/file-listing/FileRow.tsx index 4c5c5e9..b949e4e 100644 --- a/src/features/file-listing/FileRow.tsx +++ b/src/features/file-listing/FileRow.tsx @@ -18,7 +18,6 @@ import { import { DecryptedAudioFile, deleteFile, ProcessState } from './fileListingSlice'; import { useCallback, useRef } from 'react'; import { useAppDispatch } from '~/hooks'; -import coverFallback from '~/assets/no-cover.svg'; interface FileRowProps { id: string; @@ -35,7 +34,7 @@ export function FileRow({ id, file }: FileRowProps) { const decryptedName = nameWithoutExt + '.' + file.ext; const audioPlayerRef = useRef(null); - const togglePlay = useCallback(() => { + const togglePlay = () => { const player = audioPlayerRef.current; if (!player) { return; @@ -46,7 +45,7 @@ export function FileRow({ id, file }: FileRowProps) { } else { player.pause(); } - }, []); + }; const handleDeleteRow = useCallback(() => { onClose(); @@ -89,7 +88,7 @@ export function FileRow({ id, file }: FileRowProps) { objectFit="cover" src={metadata.cover} alt={`"${metadata.album}" 的专辑封面`} - fallbackSrc={coverFallback} + fallbackSrc={'/assets/no-cover.svg'} /> )}