Skip to content

Commit

Permalink
[C-2959] Fix creating playlist from track (#6868)
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptype authored Dec 6, 2023
1 parent 498c071 commit 6da7e8c
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Track,
accountActions,
accountSelectors,
cacheUsersSelectors,
cacheActions,
cacheCollectionsActions,
cacheCollectionsSelectors,
Expand All @@ -34,6 +35,7 @@ import { waitForWrite } from 'utils/sagaHelpers'

import { getUnclaimedPlaylistId } from './utils/getUnclaimedPlaylistId'
const { addLocalCollection } = savedPageActions
const { getUser } = cacheUsersSelectors

const { requestConfirmation } = confirmerActions
const { getAccountUser } = accountSelectors
Expand Down Expand Up @@ -91,6 +93,8 @@ function* optimisticallySavePlaylist(
...formFields
}

const initTrackOwner = yield* select(getUser, { id: initTrack?.owner_id })

playlist.playlist_owner_id = user_id
playlist.is_private = true
playlist.is_album = false
Expand All @@ -99,6 +103,14 @@ function* optimisticallySavePlaylist(
? [{ time: initTrack?.duration, track: initTrack.track_id }]
: []
}
playlist.tracks = initTrack
? [
{
...initTrack,
user: initTrackOwner!
}
]
: []
playlist.track_count = initTrack ? 1 : 0
playlist.permalink = collectionPage(
handle,
Expand Down

0 comments on commit 6da7e8c

Please sign in to comment.