Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions packages/common/src/api/tan-query/upload/usePublishCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
params.tracks
)

const failedTracks = publishedTracks.filter(
(track) => track.error || !track.trackId
)
if (failedTracks.length > 0) {
throw new Error(
`Failed to publish ${failedTracks.length} of ${params.tracks.length} collection tracks`
)
}

// For collection artwork, use the existing flow (not TUS) to keep things simple for now.
const { artwork } = params.collectionMetadata
const artworkBlob =
Expand All @@ -103,13 +112,11 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
const metadata = albumMetadataForCreateWithSDK(
params.collectionMetadata
)
metadata.playlistContents = publishedTracks
.filter((t) => !!t.trackId)
.map((t) => ({
timestamp: Math.round(Date.now() / 1000),
trackId: t.trackId!,
metadataTimestamp: Math.round(Date.now() / 1000)
}))
metadata.playlistContents = publishedTracks.map((track) => ({
timestamp: Math.round(Date.now() / 1000),
trackId: track.trackId!,
metadataTimestamp: Math.round(Date.now() / 1000)
}))
return await sdk.albums.createAlbum({
userId: Id.parse(userId),
imageFile: coverArtFile,
Expand All @@ -119,13 +126,11 @@ const getPublishCollectionOptions = (context: PublishCollectionContext) =>
const metadata = playlistMetadataForCreateWithSDK(
params.collectionMetadata
)
metadata.playlistContents = publishedTracks
.filter((t) => !!t.trackId)
.map((t) => ({
timestamp: Math.round(Date.now() / 1000),
trackId: t.trackId!,
metadataTimestamp: Math.round(Date.now() / 1000)
}))
metadata.playlistContents = publishedTracks.map((track) => ({
timestamp: Math.round(Date.now() / 1000),
trackId: track.trackId!,
metadataTimestamp: Math.round(Date.now() / 1000)
}))
return await sdk.playlists.createPlaylist({
userId: Id.parse(userId),
imageFile: coverArtFile,
Expand Down
Loading