add broadcast and other release type groupings

This commit is contained in:
jeffvli
2025-12-27 15:23:42 -08:00
parent 23e4574667
commit 35d8698ca0
2 changed files with 58 additions and 9 deletions
@@ -927,8 +927,10 @@ const groupAlbumsByReleaseType = (
} }
// Priority 4: Single (other non-album types) // Priority 4: Single (other non-album types)
const hasAlbumType = album.releaseTypes?.some((type) => type.toLowerCase() === 'album'); const hasSingleType = album.releaseTypes?.some(
if (!hasAlbumType) { (type) => type.toLowerCase() === 'single',
);
if (hasSingleType) {
const singleKey = 'single'; const singleKey = 'single';
if (!acc[singleKey]) { if (!acc[singleKey]) {
acc[singleKey] = []; acc[singleKey] = [];
@@ -937,12 +939,37 @@ const groupAlbumsByReleaseType = (
return acc; return acc;
} }
// Priority 5: Album // Priority 5: Broadcast (if has album type)
const albumKey = 'album'; const hasBroadcastType = album.releaseTypes?.some(
if (!acc[albumKey]) { (type) => type.toLowerCase() === 'broadcast',
acc[albumKey] = []; );
if (hasBroadcastType) {
const broadcastKey = 'broadcast';
if (!acc[broadcastKey]) {
acc[broadcastKey] = [];
}
acc[broadcastKey].push(album);
return acc;
} }
acc[albumKey].push(album);
// Priority 6: Album
const hasAlbumType = album.releaseTypes?.some((type) => type.toLowerCase() === 'album');
if (hasAlbumType) {
const albumKey = 'album';
if (!acc[albumKey]) {
acc[albumKey] = [];
}
acc[albumKey].push(album);
return acc;
}
// Priority 7: Other (catch all for unknown release types or specifically other release types)
const otherKey = 'other';
if (!acc[otherKey]) {
acc[otherKey] = [];
}
acc[otherKey].push(album);
return acc; return acc;
}, },
{} as Record<string, Album[]>, {} as Record<string, Album[]>,
@@ -995,7 +1022,15 @@ const ArtistAlbums = () => {
}, [filteredAndSortedAlbums, routeId, groupingType]); }, [filteredAndSortedAlbums, routeId, groupingType]);
const releaseTypeEntries = useMemo(() => { const releaseTypeEntries = useMemo(() => {
const priorityOrder = ['album', 'ep', 'single', 'compilation', 'appears-on']; const priorityOrder = [
'album',
'ep',
'single',
'broadcast',
'other',
'compilation',
'appears-on',
];
const getPriority = (releaseType: string) => { const getPriority = (releaseType: string) => {
const index = priorityOrder.indexOf(releaseType); const index = priorityOrder.indexOf(releaseType);
return index === -1 ? 999 : index; return index === -1 ? 999 : index;
@@ -1015,6 +1050,11 @@ const ArtistAlbums = () => {
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
}); });
break; break;
case 'broadcast':
displayName = t('releaseType.primary.broadcast', {
postProcess: 'sentenceCase',
});
break;
case 'compilation': case 'compilation':
displayName = t('releaseType.secondary.compilation', { displayName = t('releaseType.secondary.compilation', {
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
@@ -1025,6 +1065,11 @@ const ArtistAlbums = () => {
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
}); });
break; break;
case 'other':
displayName = t('releaseType.primary.other', {
postProcess: 'sentenceCase',
});
break;
case 'single': case 'single':
displayName = t('releaseType.primary.single', { displayName = t('releaseType.primary.single', {
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
+5 -1
View File
@@ -68,7 +68,11 @@ export const useAppStore = createWithEqualityFn<AppSlice>()(
}, },
setAlbumArtistDetailSort: (sortBy, sortOrder) => { setAlbumArtistDetailSort: (sortBy, sortOrder) => {
set((state) => { set((state) => {
state.albumArtistDetailSort = { ...state.albumArtistDetailSort, sortBy, sortOrder }; state.albumArtistDetailSort = {
...state.albumArtistDetailSort,
sortBy,
sortOrder,
};
}); });
}, },
setAppStore: (data) => { setAppStore: (data) => {