From 6da7e8c010a36b90e47e2ae74ba45d822066d91d Mon Sep 17 00:00:00 2001 From: Sebastian Klingler Date: Wed, 6 Dec 2023 14:58:56 -0600 Subject: [PATCH] [C-2959] Fix creating playlist from track (#6868) --- .../store/cache/collections/createPlaylistSaga.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts b/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts index 2e9de0e1884..f961e52557f 100644 --- a/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts +++ b/packages/web/src/common/store/cache/collections/createPlaylistSaga.ts @@ -10,6 +10,7 @@ import { Track, accountActions, accountSelectors, + cacheUsersSelectors, cacheActions, cacheCollectionsActions, cacheCollectionsSelectors, @@ -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 @@ -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 @@ -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,