fix empty sha256 (for old server upload before blossom)

This commit is contained in:
Quentin 2024-07-25 11:44:37 +02:00
parent 37bc592a6d
commit 14087711a0

View File

@ -37,6 +37,7 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) =>
const { distribution } = useServerInfo();
const fileMetaEventsByHash = useFileMetaEventsByHash();
const { handleSelectBlob, selectedBlobs, setSelectedBlobs } = useBlobSelection(blobs);
const images = useMemo(
() => blobs.filter(b => b.type?.startsWith('image/')).sort((a, b) => (a.uploaded > b.uploaded ? -1 : 1)), // descending
[blobs]
@ -99,8 +100,8 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) =>
};
const createNewCollection = () => {
// TODO Show new collction dialog
console.log('Show new collction dialog');
// TODO Show new collection dialog
console.log('Show new collection dialog');
};
return (
@ -132,7 +133,7 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) =>
<FolderIcon /> Collection 2 (NOT IMPLEMENTED YET)
</a>
</li>
<li className=" border-t-2 border-base-300">
<li className="border-t-2 border-base-300">
<a onClick={() => createNewCollection()}>
<FolderPlusIcon /> new collection (NOT IMPLEMENTED YET)
</a>
@ -166,21 +167,21 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) =>
/>
</div>
{mode == 'gallery' && (
{mode === 'gallery' && (
<ImageBlobList images={images} selectedBlobs={selectedBlobs} handleSelectBlob={handleSelectBlob} />
)}
{mode == 'video' && (
{mode === 'video' && (
<VideoBlobList videos={videos} selectedBlobs={selectedBlobs} handleSelectBlob={handleSelectBlob} />
)}
{mode == 'audio' && (
{mode === 'audio' && (
<AudioBlobList audioFiles={audioFiles} selectedBlobs={selectedBlobs} handleSelectBlob={handleSelectBlob} />
)}
{mode == 'docs' && <DocumentBlobList docs={docs} />}
{mode === 'docs' && <DocumentBlobList docs={docs} />}
{mode == 'list' && (
{mode === 'list' && (
<div className="blob-list">
<table className="table hover">
<thead>
@ -194,32 +195,34 @@ const BlobList = ({ blobs, onDelete, title, className = '' }: BlobListProps) =>
</tr>
</thead>
<tbody>
{blobs.map((blob: BlobDescriptor) => (
{blobs.map(blob => (
<tr
className={`hover ${selectedBlobs[blob.sha256] ? 'selected' : ''}`}
className={`hover ${selectedBlobs[blob.sha256? blob.sha256: blob.url] ? 'selected' : ''}`}
key={blob.sha256}
onClick={e => handleSelectBlob(blob.sha256, e)}
onClick={e => handleSelectBlob(blob.sha256? blob.sha256 : blob.url, e)}
>
<td className="whitespace-nowrap w-12">
<input
type="checkbox"
className="checkbox checkbox-primary checkbox-sm mr-2"
checked={!!selectedBlobs[blob.sha256]}
onChange={e => handleSelectBlob(blob.sha256, e)}
checked={!!selectedBlobs[blob.sha256? blob.sha256 : blob.url]}
onChange={e => handleSelectBlob(blob.sha256? blob.sha256 : blob.url, e)}
onClick={e => e.stopPropagation()}
/>
{getMimeTypeIcon(blob.type)}
</td>
<td className="whitespace-nowrap">
<a className="link link-primary" href={blob.url} target="_blank">
{blob.sha256.slice(0, 15)}
{blob.sha256 ? blob.sha256.slice(0, 15) : blob.url.slice(blob.url.length - 15)}
</a>
</td>
<td>
<Badges blob={blob} />
<span className="text-warning tooltip" data-tip="Not distributed to any other server">
{distribution[blob.sha256].servers.length == 1 && <ExclamationTriangleIcon />}
</span>
{distribution[blob.sha256]?.servers.length === 1 && (
<span className="text-warning tooltip" data-tip="Not distributed to any other server">
<ExclamationTriangleIcon />
</span>
)}
</td>
<td>{formatFileSize(blob.size)}</td>
<td>{formatDate(blob.uploaded)}</td>