Fix: Kuratoren-Scope für Specials & Audio-Playback im Curator-Dashboard

This commit is contained in:
Hördle Bot
2025-12-03 13:25:43 +01:00
parent f691384a34
commit 5e1700712e
2 changed files with 30 additions and 5 deletions

View File

@@ -30,9 +30,19 @@ function curatorCanEditSong(context: StaffContext, song: any, assignments: { gen
if (context.role === 'admin') return true;
const songGenreIds = (song.genres || []).map((g: any) => g.id);
// `song.specials` enthält bereits `Special`-Objekte mit einem `id`-Feld.
// Wir verwenden daher konsistent `s.id` statt eines (nicht existenten) `specialId`.
const songSpecialIds = (song.specials || []).map((s: any) => s.id);
// `song.specials` kann je nach Context entweder ein Array von
// - `Special` (mit `id`)
// - `SpecialSong` (mit `specialId`)
// - `SpecialSong` (mit Relation `special.id`)
// sein. Wir normalisieren hier auf reine Zahlen-IDs.
const songSpecialIds = (song.specials || [])
.map((s: any) => {
if (s?.id != null) return s.id;
if (s?.specialId != null) return s.specialId;
if (s?.special?.id != null) return s.special.id;
return undefined;
})
.filter((id: any): id is number => typeof id === 'number');
// Songs ohne Genres/Specials sind für Kuratoren generell editierbar
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
@@ -49,7 +59,14 @@ function curatorCanDeleteSong(context: StaffContext, song: any, assignments: { g
if (context.role === 'admin') return true;
const songGenreIds = (song.genres || []).map((g: any) => g.id);
const songSpecialIds = (song.specials || []).map((s: any) => s.id);
const songSpecialIds = (song.specials || [])
.map((s: any) => {
if (s?.id != null) return s.id;
if (s?.specialId != null) return s.specialId;
if (s?.special?.id != null) return s.special.id;
return undefined;
})
.filter((id: any): id is number => typeof id === 'number');
const allGenresAllowed = songGenreIds.every((id: number) => assignments.genreIds.has(id));
const allSpecialsAllowed = songSpecialIds.every((id: number) => assignments.specialIds.has(id));
@@ -86,7 +103,9 @@ export async function GET(request: NextRequest) {
visibleSongs = songs.filter(song => {
const songGenreIds = song.genres.map(g => g.id);
const songSpecialIds = song.specials.map(ss => ss.specialId);
// `song.specials` ist hier ein Array von SpecialSong mit Relation `special`,
// wir nutzen konsistent die Special-ID.
const songSpecialIds = song.specials.map(ss => ss.special.id);
// Songs ohne Genres/Specials sind immer sichtbar
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {

View File

@@ -332,6 +332,12 @@ export default function CuratorPage() {
setPlayingSongId(null);
setAudioElement(null);
});
// Reset Zustand, wenn der Track zu Ende gespielt ist
audio.onended = () => {
setPlayingSongId(null);
setAudioElement(null);
};
}
};