Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
Auto favorite tracks on purchase PAY-1772 (#4048)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikki Kang <kangaroo233@gmail.com>
  • Loading branch information
nicoback2 and nicoback authored Sep 7, 2023
1 parent 91c49fa commit 17284b7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/common/src/store/purchase-content/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BN from 'bn.js'
import { takeLatest } from 'redux-saga/effects'
import { call, put, race, select, take } from 'typed-redux-saga'

import { Name } from 'models/Analytics'
import { FavoriteSource, Name } from 'models/Analytics'
import { ErrorLevel } from 'models/ErrorReporting'
import { ID } from 'models/Identifiers'
import { isPremiumContentUSDCPurchaseGated } from 'models/Track'
Expand All @@ -23,6 +23,7 @@ import { getUSDCUserBank } from 'store/buy-usdc/utils'
import { getTrack } from 'store/cache/tracks/selectors'
import { getUser } from 'store/cache/users/selectors'
import { getContext } from 'store/effects'
import { saveTrack } from 'store/social/tracks/actions'
import { BN_USDC_CENT_WEI, ceilingBNUSDCToNearestCent } from 'utils/wallet'

import { pollPremiumTrack } from '../premium-content/sagas'
Expand Down Expand Up @@ -217,6 +218,11 @@ function* doStartPurchaseContentFlow({
// confirm purchase
yield* pollForPurchaseConfirmation({ contentId, contentType })

// auto-favorite the purchased item
if (contentType === ContentType.TRACK) {
yield* put(saveTrack(contentId, FavoriteSource.IMPLICIT))
}

// finish
yield* put(purchaseConfirmed())

Expand Down

0 comments on commit 17284b7

Please sign in to comment.