Fix: Kuratoren-Scope für Specials & Audio-Playback im Curator-Dashboard
This commit is contained in:
@@ -30,9 +30,19 @@ function curatorCanEditSong(context: StaffContext, song: any, assignments: { gen
|
|||||||
if (context.role === 'admin') return true;
|
if (context.role === 'admin') return true;
|
||||||
|
|
||||||
const songGenreIds = (song.genres || []).map((g: any) => g.id);
|
const songGenreIds = (song.genres || []).map((g: any) => g.id);
|
||||||
// `song.specials` enthält bereits `Special`-Objekte mit einem `id`-Feld.
|
// `song.specials` kann je nach Context entweder ein Array von
|
||||||
// Wir verwenden daher konsistent `s.id` statt eines (nicht existenten) `specialId`.
|
// - `Special` (mit `id`)
|
||||||
const songSpecialIds = (song.specials || []).map((s: any) => s.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
|
// Songs ohne Genres/Specials sind für Kuratoren generell editierbar
|
||||||
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
|
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;
|
if (context.role === 'admin') return true;
|
||||||
|
|
||||||
const songGenreIds = (song.genres || []).map((g: any) => g.id);
|
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 allGenresAllowed = songGenreIds.every((id: number) => assignments.genreIds.has(id));
|
||||||
const allSpecialsAllowed = songSpecialIds.every((id: number) => assignments.specialIds.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 => {
|
visibleSongs = songs.filter(song => {
|
||||||
const songGenreIds = song.genres.map(g => g.id);
|
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
|
// Songs ohne Genres/Specials sind immer sichtbar
|
||||||
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
|
if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
|
||||||
|
|||||||
@@ -332,6 +332,12 @@ export default function CuratorPage() {
|
|||||||
setPlayingSongId(null);
|
setPlayingSongId(null);
|
||||||
setAudioElement(null);
|
setAudioElement(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Reset Zustand, wenn der Track zu Ende gespielt ist
|
||||||
|
audio.onended = () => {
|
||||||
|
setPlayingSongId(null);
|
||||||
|
setAudioElement(null);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user