Skip to content

Commit

Permalink
Fix serializing media items
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Aug 28, 2024
1 parent 7218946 commit 48fbd78
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/utils/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 48fbd78

Please sign in to comment.