diff --git a/app/pages/admin/songs.vue b/app/pages/admin/songs.vue index 45d57e2..a9c7eff 100644 --- a/app/pages/admin/songs.vue +++ b/app/pages/admin/songs.vue @@ -67,6 +67,11 @@ const modalFields: Field[] = [ { key: "lyrics.synced", label: "Synced lyrics", type: "checkbox" }, ] +const serializeLyrics = (lyrics: Track["lyrics"] | undefined) => { + if (!lyrics?.text?.trim()) return JSON.stringify(null) + return JSON.stringify(lyrics) +} + const showModal = ref(false) const item = ref(undefined) @@ -77,7 +82,7 @@ const save = async (value: any) => { method: "PATCH", data: { ...value, - lyrics: JSON.stringify(value.lyrics), + lyrics: serializeLyrics(value.lyrics), }, params: { id: value._id }, forceFormData: true, @@ -95,7 +100,7 @@ const save = async (value: any) => { method: "POST", data: { ...value, - lyrics: JSON.stringify(value.lyrics), + lyrics: serializeLyrics(value.lyrics), }, }) diff --git a/app/utils/types.ts b/app/utils/types.ts index 25c6128..107a31c 100644 --- a/app/utils/types.ts +++ b/app/utils/types.ts @@ -24,7 +24,7 @@ export interface Track extends Base { lyrics: { synced: boolean text: string - } + } | null album: Album artists: Artist[] durationInSeconds: number