Fix single track artist fields

This commit is contained in:
lucast committed 2026-09-26 00:21:59 +02:00
1 parent 661b9341d7
commit 5e3f3ef6a2
1 file changed
+9 -3
+9 -3
View File
@@ -100,6 +100,12 @@ const serializeLyrics = (lyrics: Track["lyrics"] | undefined) => {
return JSON.stringify(lyrics) return JSON.stringify(lyrics)
} }
const getArtistIds = (artists: Array<string | Option> = []) =>
artists.map((artist) => (typeof artist === "string" ? artist : artist.value))
const getOptionId = (option: string | Option) =>
typeof option === "string" ? option : option.value
const showModal = ref<boolean>(false) const showModal = ref<boolean>(false)
const item = ref<Track | undefined>(undefined) const item = ref<Track | undefined>(undefined)
@@ -145,8 +151,8 @@ const save = async (value: any) => {
method: "POST", method: "POST",
data: { data: {
name: `${value.name} - Single`, name: `${value.name} - Single`,
artists: value.artists.map((artist: Option) => artist.value), artists: getArtistIds(value.artists),
genres: value.genre.value, genre: getOptionId(value.genre),
file: value.cover, file: value.cover,
}, },
}) })
@@ -164,7 +170,7 @@ const save = async (value: any) => {
data: { data: {
...value, ...value,
album: value.album?.value ?? value.album, album: value.album?.value ?? value.album,
artists: value.artists.map((artist: Option) => artist.value), artists: getArtistIds(value.artists),
lyrics: serializeLyrics(value.lyrics), lyrics: serializeLyrics(value.lyrics),
}, },
}) })