chore: use object instead of array for file listing

This commit is contained in:
鲁树人
2023-05-08 15:54:00 +01:00
parent 38aa81b5bc
commit 3b264f380f
2 changed files with 9 additions and 11 deletions

View File

@@ -10,8 +10,8 @@ export function FileListing() {
useEffect(() => {
// FIXME: Remove test data
if (files.length === 0) {
dispatch(addNewFile({ id: String(Date.now()), fileName: '测试文件名.mgg', blobURI: '' }));
if (Object.keys(files).length === 0) {
dispatch(addNewFile({ id: 'dummy', fileName: '测试文件名.mgg', blobURI: '' }));
}
}, []);
@@ -26,8 +26,8 @@ export function FileListing() {
</Tr>
</Thead>
<Tbody>
{files.map((file) => (
<Tr key={file.id}>
{Object.entries(files).map(([id, file]) => (
<Tr key={id}>
<Td>
{file.metadata.cover && <Avatar size="sm" name="专辑封面" src={file.metadata.cover} />}
{!file.metadata.cover && <Text></Text>}