From 48fbd78c1598f7c46b0dbd58cb0241e6de453ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Wed, 28 Aug 2024 14:31:58 +0200 Subject: [PATCH] Fix serializing media items --- src/utils/serialize.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/utils/serialize.js b/src/utils/serialize.js index dc4daaab..b3fec971 100644 --- a/src/utils/serialize.js +++ b/src/utils/serialize.js @@ -12,6 +12,31 @@ export function serializePlaylist(model) { }; } +/** + * @param {{ + * id: import('../schema.js').MediaID, + * sourceType: string, + * sourceID: string, + * sourceData?: import('type-fest').JsonObject | null, + * artist: string, + * title: string, + * duration: number, + * thumbnail: string, + * }} model + */ +export function serializeMedia(model) { + return { + _id: model.id, + sourceType: model.sourceType, + sourceID: model.sourceID, + sourceData: model.sourceData, + artist: model.artist, + title: model.title, + duration: model.duration, + thumbnail: model.thumbnail, + } +} + /** * @param {{ * id: import('../schema.js').PlaylistItemID, @@ -27,7 +52,7 @@ export function serializePlaylist(model) { export function serializePlaylistItem(model) { return { _id: model.id, - media: model.media, + media: serializeMedia(model.media), artist: model.artist, title: model.title, start: model.start,