From c2ac9a5481b096a0ad04bfdb226aa6a7c3d2e3b9 Mon Sep 17 00:00:00 2001 From: florian <> Date: Sat, 29 Jun 2024 19:10:09 +0200 Subject: [PATCH] fix: Fixed missing audio without tags --- bun.lockb | Bin 172137 -> 172137 bytes .../AudioBlobList/AudioBlobList.tsx | 47 ++++++++++++------ src/components/BlobList/BlobList.tsx | 10 ++-- src/pages/Upload.tsx | 4 +- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/bun.lockb b/bun.lockb index 7969db4d222164b042730595a057a5ffd080d6b2..8f256ddc7796dfca248480475f3edac78fa262e3 100755 GIT binary patch delta 150 zcmV;H0BQf}zzXTW3Xm=!Jexz&Do0Iol)c zqW#w@QCkSECVrVG8qEvZB^W%X4Yov!6EE(tgDuOqEz1G^2LU;^EYkrUV*xq0N;U!? EYO`NNkpKVy delta 144 zcmV;B0B`^4zzXTW3Xm=!!8grc5y{JuUy72qgpZ4%>nhKUp461xN%!Ph_@Cexu}*e1 zlY~1ov-majlt2qVJu!Mnpfn*~nV0FRdEw2{qq<0DYC%bp%b!o`fxBZ0+?npQwy%qn yaPL_z{xjb)7{S-n4Lw~=AuBgmk?Vsk%eO7d0saR8IJYd*0UcujIJZhR0v~F3zed~u diff --git a/src/components/AudioBlobList/AudioBlobList.tsx b/src/components/AudioBlobList/AudioBlobList.tsx index 1143450..318dbce 100644 --- a/src/components/AudioBlobList/AudioBlobList.tsx +++ b/src/components/AudioBlobList/AudioBlobList.tsx @@ -1,24 +1,36 @@ import { formatFileSize, formatDate } from '../../utils/utils'; import { ClipboardDocumentIcon, TrashIcon } from '@heroicons/react/24/outline'; import { BlobDescriptor } from 'blossom-client-sdk'; -import { AudioBlob, fetchId3Tag } from '../../utils/id3'; +import { AudioBlob, ID3Tag, fetchId3Tag } from '../../utils/id3'; import { useQueries } from '@tanstack/react-query'; import { useGlobalContext } from '../../GlobalState'; import { PauseIcon, PlayIcon } from '@heroicons/react/24/solid'; +import { HandleSelectBlobType } from '../BlobList/useBlobSelection'; type AudioBlobListProps = { audioFiles: BlobDescriptor[]; - onDelete?: (blob: BlobDescriptor) => void; + handleSelectBlob: HandleSelectBlobType; + selectedBlobs: { [key: string]: boolean }; }; -const AudioBlobList = ({ audioFiles, onDelete }: AudioBlobListProps) => { +const AudioBlobList = ({ audioFiles, handleSelectBlob, selectedBlobs }: AudioBlobListProps) => { const { dispatch, state } = useGlobalContext(); const audioFilesWithId3 = useQueries({ queries: audioFiles.map(af => ({ queryKey: ['id3', af.sha256], queryFn: async () => { - const id3Tag = await fetchId3Tag(af.sha256, af.url); + let id3Tag: + | { + id3: ID3Tag; + coverFull?: string | undefined; + } + | undefined; + try { + id3Tag = await fetchId3Tag(af.sha256, af.url); + } catch (e) { + // ignore + } return { ...af, id3: id3Tag?.id3 } as AudioBlob; }, staleTime: 1000 * 60 * 5, @@ -70,7 +82,21 @@ const AudioBlobList = ({ audioFiles, onDelete }: AudioBlobListProps) => { )} -
+
{ + e.stopPropagation(); + handleSelectBlob(blob.data.sha256, e); + }} + > + handleSelectBlob(blob.data.sha256, e)} + onClick={e => e.stopPropagation()} + /> + {formatFileSize(blob.data.size)} {formatDate(blob.data.uploaded)}
@@ -84,17 +110,6 @@ const AudioBlobList = ({ audioFiles, onDelete }: AudioBlobListProps) => { - {onDelete && ( - - onDelete(blob.data)} - className="link link-primary tooltip" - data-tip="Delete this blob" - > - - - - )}
) diff --git a/src/components/BlobList/BlobList.tsx b/src/components/BlobList/BlobList.tsx index f6e9ea6..85d91e9 100644 --- a/src/components/BlobList/BlobList.tsx +++ b/src/components/BlobList/BlobList.tsx @@ -60,7 +60,7 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) => { + onClick={e => { e.stopPropagation(); navigator.clipboard.writeText(blob.url); }} @@ -128,9 +128,13 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) => )} - {mode == 'video' && } + {mode == 'video' && ( + + )} - {mode == 'audio' && } + {mode == 'audio' && ( + + )} {mode == 'docs' && } diff --git a/src/pages/Upload.tsx b/src/pages/Upload.tsx index 44d8daf..1795774 100644 --- a/src/pages/Upload.tsx +++ b/src/pages/Upload.tsx @@ -232,7 +232,7 @@ function Upload() { return ( <>

Upload

- {/* + - */} +