Skip to content

Commit

Permalink
[PAY-2415][PAY-2417][PAY-2419][PAY-2420][PAY-2437] Fix lossless issues (
Browse files Browse the repository at this point in the history
#7483)

Co-authored-by: Saliou Diallo <saliou@audius.co>
  • Loading branch information
sddioulde and Saliou Diallo authored Feb 7, 2024
1 parent abc0d1e commit e13220b
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 87 deletions.
3 changes: 2 additions & 1 deletion packages/common/src/models/Stems.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Track } from '~/models/Track'
import { Nullable } from '~/utils'

export enum StemCategory {
INSTRUMENTAL = 'INSTRUMENTAL',
Expand Down Expand Up @@ -32,7 +33,7 @@ export const stemCategoryFriendlyNames = {

export type StemUpload = {
metadata: Track
category: StemCategory
category: Nullable<StemCategory>
allowDelete: boolean
allowCategorySwitch: boolean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
display: inline-flex;
flex-shrink: 1;
gap: var(--unit-2);
flex-wrap: wrap;
}

.selectedValue {
Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/components/upload/TrackPreviewNew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react'

import { StemCategory, stemCategoryFriendlyNames } from '@audius/common/models'
import { FeatureFlags } from '@audius/common/services'
import { Nullable } from '@audius/common/utils'
import {
Box,
FilterButton,
Expand Down Expand Up @@ -61,7 +62,7 @@ type TrackPreviewProps = {
isTitleEditable?: boolean
onEditTitle?: (title: string) => void
isStem?: boolean
stemCategory?: StemCategory
stemCategory?: Nullable<StemCategory>
onEditStemCategory?: (stemCategory: StemCategory) => void
isEdit?: boolean
isDisabled?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
display: inline-flex;
flex-shrink: 1;
gap: var(--unit-2);
flex-wrap: wrap;
}

.nftOwner {
Expand Down
85 changes: 51 additions & 34 deletions packages/web/src/pages/upload-page/fields/AccessAndSaleField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
CollectibleGatedConditions,
FollowGatedConditions,
TipGatedConditions,
Download,
USDCPurchaseConditions
} from '@audius/common/models'
import { accountSelectors } from '@audius/common/store'
Expand Down Expand Up @@ -47,15 +46,16 @@ import { REMIX_OF } from './RemixSettingsField'
import { getCombinedDefaultGatedConditionValues } from './helpers'
import {
AccessAndSaleFormValues,
DOWNLOAD,
DOWNLOAD_CONDITIONS,
DOWNLOAD_REQUIRES_FOLLOW,
FIELD_VISIBILITY,
GateKeeper,
IS_DOWNLOADABLE,
IS_DOWNLOAD_GATED,
IS_SCHEDULED_RELEASE,
IS_STREAM_GATED,
IS_UNLISTED,
LAST_GATE_KEEPER,
PREVIEW,
PRICE,
PRICE_HUMANIZED,
Expand Down Expand Up @@ -247,14 +247,14 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
DOWNLOAD_CONDITIONS
)
const [{ value: isDownloadable }, , { setValue: setIsDownloadable }] =
useField(IS_DOWNLOADABLE)
useTrackField<boolean>(IS_DOWNLOADABLE)
const [
{ value: downloadRequiresFollow },
,
{ setValue: setDownloadRequiresFollow }
] = useField(DOWNLOAD_REQUIRES_FOLLOW)
const [{ value: download }, , { setValue: setDownload }] =
useTrackField<Download>(DOWNLOAD)
] = useTrackField<boolean>(DOWNLOAD_REQUIRES_FOLLOW)
const [{ value: lastGateKeeper }, , { setValue: setLastGateKeeper }] =
useTrackField<GateKeeper>(LAST_GATE_KEEPER)

const isRemix = !isEmpty(remixOfValue?.tracks)

Expand Down Expand Up @@ -286,7 +286,7 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
set(initialValues, DOWNLOAD_CONDITIONS, downloadConditions)
set(initialValues, IS_DOWNLOADABLE, isDownloadable)
set(initialValues, DOWNLOAD_REQUIRES_FOLLOW, downloadRequiresFollow)
set(initialValues, DOWNLOAD, download)
set(initialValues, LAST_GATE_KEEPER, lastGateKeeper ?? {})

let availabilityType = StreamTrackAvailabilityType.PUBLIC
if (isUsdcGated) {
Expand Down Expand Up @@ -326,10 +326,10 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
downloadConditions,
isDownloadable,
downloadRequiresFollow,
download,
fieldVisibility,
preview,
isScheduledRelease
isScheduledRelease,
lastGateKeeper
])

const handleSubmit = useCallback(
Expand All @@ -339,6 +339,7 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
const specialAccessType = get(values, SPECIAL_ACCESS_TYPE)
const fieldVisibility = get(values, FIELD_VISIBILITY)
const streamConditions = get(values, STREAM_CONDITIONS)
const lastGateKeeper = get(values, LAST_GATE_KEEPER)

setFieldVisibilityValue({
...defaultFieldVisibility,
Expand All @@ -348,7 +349,6 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
setIsStreamGated(false)
setStreamConditionsValue(null)
setPreviewValue(undefined)

// For gated options, extract the correct stream conditions based on the selected availability type
switch (availabilityType) {
case StreamTrackAvailabilityType.USDC_PURCHASE: {
Expand All @@ -367,10 +367,15 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
setDownloadConditionsValue(conditions)
setIsDownloadable(true)
setDownloadRequiresFollow(false)
setDownload({
cid: null,
is_downloadable: true,
requires_follow: false
const downloadableGateKeeper =
isDownloadable &&
lastGateKeeper.downloadable === 'stemsAndDownloads'
? 'stemsAndDownloads'
: 'accessAndSale'
setLastGateKeeper({
...lastGateKeeper,
access: 'accessAndSale',
downloadable: downloadableGateKeeper
})
break
}
Expand All @@ -379,26 +384,23 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
const { follow_user_id } = streamConditions as FollowGatedConditions
setStreamConditionsValue({ follow_user_id })
setDownloadConditionsValue({ follow_user_id })
setDownloadRequiresFollow(true)
setDownload({
cid: null,
is_downloadable: true,
requires_follow: true
})
if (isDownloadable) {
setDownloadRequiresFollow(true)
}
} else {
const { tip_user_id } = streamConditions as TipGatedConditions
setStreamConditionsValue({ tip_user_id })
setDownloadConditionsValue({ tip_user_id })
setDownloadRequiresFollow(false)
setDownload({
cid: null,
is_downloadable: true,
requires_follow: false
})
if (isDownloadable) {
setDownloadRequiresFollow(false)
}
}
setIsStreamGated(true)
setIsDownloadGated(true)
setIsDownloadable(true)
setLastGateKeeper({
...lastGateKeeper,
access: 'accessAndSale'
})
break
}
case StreamTrackAvailabilityType.COLLECTIBLE_GATED: {
Expand All @@ -408,12 +410,12 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
setStreamConditionsValue({ nft_collection })
setIsDownloadGated(true)
setDownloadConditionsValue({ nft_collection })
setIsDownloadable(true)
setDownloadRequiresFollow(false)
setDownload({
cid: null,
is_downloadable: true,
requires_follow: false
if (isDownloadable) {
setDownloadRequiresFollow(false)
}
setLastGateKeeper({
...lastGateKeeper,
access: 'accessAndSale'
})
break
}
Expand All @@ -423,10 +425,24 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
remixes: fieldVisibility?.remixes ?? defaultFieldVisibility.remixes
})
setIsUnlistedValue(true)
if (lastGateKeeper.access === 'accessAndSale') {
setIsDownloadGated(false)
setDownloadConditionsValue(null)
}
if (lastGateKeeper.downloadable === 'accessAndSale') {
setIsDownloadable(false)
}
break
}
case StreamTrackAvailabilityType.PUBLIC: {
setIsUnlistedValue(false)
if (lastGateKeeper.access === 'accessAndSale') {
setIsDownloadGated(false)
setDownloadConditionsValue(null)
}
if (lastGateKeeper.downloadable === 'accessAndSale') {
setIsDownloadable(false)
}
break
}
}
Expand All @@ -440,8 +456,9 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
setDownloadConditionsValue,
setIsDownloadable,
setDownloadRequiresFollow,
setDownload,
setPreviewValue,
setLastGateKeeper,
isDownloadable,
isUnlisted
]
)
Expand Down
Loading

0 comments on commit e13220b

Please sign in to comment.