Allow clearing song lyrics
This commit is contained in:
1 parent
a6e8bb51c5
commit
8ee6164218
2 files changed
+8
-3
No files matched your search
@@ -67,6 +67,11 @@ const modalFields: Field[] = [
|
|||||||
{ key: "lyrics.synced", label: "Synced lyrics", type: "checkbox" },
|
{ 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<boolean>(false)
|
const showModal = ref<boolean>(false)
|
||||||
const item = ref<Track | undefined>(undefined)
|
const item = ref<Track | undefined>(undefined)
|
||||||
|
|
||||||
@@ -77,7 +82,7 @@ const save = async (value: any) => {
|
|||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
data: {
|
data: {
|
||||||
...value,
|
...value,
|
||||||
lyrics: JSON.stringify(value.lyrics),
|
lyrics: serializeLyrics(value.lyrics),
|
||||||
},
|
},
|
||||||
params: { id: value._id },
|
params: { id: value._id },
|
||||||
forceFormData: true,
|
forceFormData: true,
|
||||||
@@ -95,7 +100,7 @@ const save = async (value: any) => {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
...value,
|
...value,
|
||||||
lyrics: JSON.stringify(value.lyrics),
|
lyrics: serializeLyrics(value.lyrics),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ export interface Track extends Base {
|
|||||||
lyrics: {
|
lyrics: {
|
||||||
synced: boolean
|
synced: boolean
|
||||||
text: string
|
text: string
|
||||||
}
|
} | null
|
||||||
album: Album
|
album: Album
|
||||||
artists: Artist[]
|
artists: Artist[]
|
||||||
durationInSeconds: number
|
durationInSeconds: number
|
||||||
|
|||||||
Reference in new issue
Block a user