mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
simplify disc/subtitle for album list
This commit is contained in:
parent
b41a1a8b15
commit
8a8542ddb1
3 changed files with 32 additions and 20 deletions
|
|
@ -105,28 +105,32 @@ export const AlbumDetailContent = ({ tableRef, background }: AlbumDetailContentP
|
|||
return [];
|
||||
}
|
||||
|
||||
const uniqueDiscNumbers = new Set(detailQuery.data?.songs.map((s) => s.discNumber));
|
||||
let discNumber = -1;
|
||||
let discSubtitle: string | null = null;
|
||||
|
||||
const rowData: (QueueSong | { id: string; name: string })[] = [];
|
||||
const discTranslated = t('common.disc', { postProcess: 'upperCase' });
|
||||
|
||||
for (const discNumber of uniqueDiscNumbers.values()) {
|
||||
const songsByDiscNumber = detailQuery.data?.songs.filter(
|
||||
(s) => s.discNumber === discNumber,
|
||||
);
|
||||
for (const song of detailQuery.data.songs) {
|
||||
if (song.discNumber !== discNumber || song.discSubtitle !== discSubtitle) {
|
||||
discNumber = song.discNumber;
|
||||
discSubtitle = song.discSubtitle;
|
||||
|
||||
const discSubtitle = songsByDiscNumber?.[0]?.discSubtitle;
|
||||
const discName = [`Disc ${discNumber}`.toLocaleUpperCase(), discSubtitle]
|
||||
.filter(Boolean)
|
||||
.join(': ');
|
||||
let id = `disc-${discNumber}`;
|
||||
let name = `${discTranslated} ${discNumber}`;
|
||||
|
||||
rowData.push({
|
||||
id: `disc-${discNumber}`,
|
||||
name: discName,
|
||||
});
|
||||
rowData.push(...songsByDiscNumber);
|
||||
if (discSubtitle) {
|
||||
id += `-${discSubtitle}`;
|
||||
name += `: ${discSubtitle}`;
|
||||
}
|
||||
|
||||
rowData.push({ id, name });
|
||||
}
|
||||
rowData.push(song);
|
||||
}
|
||||
|
||||
return rowData;
|
||||
}, [detailQuery.data?.songs]);
|
||||
}, [detailQuery.data?.songs, t]);
|
||||
|
||||
const [pagination, setPagination] = useSetState({
|
||||
artist: 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue