Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled release follow ons: usdc to special access, persist selected date, etc #7135

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion packages/common/src/store/cache/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const forceUpdateKeys = new Set([
'followee_reposts',
'followee_saves',
'associated_wallets',
'associated_sol_wallets'
'associated_sol_wallets',
'premium_conditions'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with scheduled releases, you can freely change from usdc to special access. sometimes there was merging behavior so a track would have both conditions. this prevents that merging behavior.

])

// Customize lodash recursive merge to never merge
Expand Down
1 change: 0 additions & 1 deletion packages/discovery-provider/src/tasks/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class PlaylistMetadata(TypedDict):
"track_cid",
"duration",
"is_available",
"is_scheduled_release",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove is_scheduled_release here to fix case where a track is uploaded as hidden, then a future release date should make it a scheduled release. removing it as immutable here so a track can go from false to true.

}

immutable_user_fields = immutable_fields | {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Dimensions, View } from 'react-native'

import IconHidden from 'app/assets/images/iconHidden.svg'
import { Text } from 'app/components/core'
import { HelpCallout } from 'app/components/help-callout/HelpCallout'
import { useSetTrackAvailabilityFields } from 'app/hooks/useSetTrackAvailabilityFields'
import { makeStyles } from 'app/styles'
import { useColor } from 'app/utils/theme'
Expand All @@ -17,6 +18,7 @@ const messages = {
hidden: 'Hidden',
hiddenSubtitle:
"Hidden tracks won't be visible to your followers. Only you will see them on your profile. Anyone who has the link will be able to listen.",
noHiddenHint: 'Scheduled tracks are hidden by default until release.',
hideTrack: 'Hide Track',
showGenre: 'Show Genre',
showMood: 'Show Mood',
Expand Down Expand Up @@ -70,12 +72,16 @@ const useStyles = makeStyles(({ spacing, palette }) => ({
},
switch: {
marginTop: spacing(2)
},
noHidden: {
marginTop: spacing(4)
}
}))

export const HiddenAvailability = ({
selected,
disabled = false
disabled = false,
isScheduledRelease
}: TrackAvailabilitySelectionProps) => {
const styles = useStyles()
const secondary = useColor('secondary')
Expand Down Expand Up @@ -121,6 +127,9 @@ export const HiddenAvailability = ({
{messages.hidden}
</Text>
</View>
{isUnlisted && isScheduledRelease ? (
<HelpCallout style={styles.noHidden} content={messages.noHiddenHint} />
) : null}
{selected ? (
<>
<View style={styles.subtitleContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export type TrackAvailabilitySelectionProps = {
disabled?: boolean
disabledContent?: boolean
previousPremiumConditions?: Nullable<PremiumConditions>
isScheduledRelease?: boolean
isUnlisted?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ export const AccessAndSaleScreen = () => {
<HiddenAvailability
selected={availability === TrackAvailabilityType.HIDDEN}
disabled={noHidden}
isScheduledRelease={isScheduledRelease}
isUnlisted={isUnlisted}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,8 @@ const useStyles = makeStyles(({ palette, spacing }) => ({
}
}))

const data: ListSelectionData[] = [
{
label: ReleaseDateType.RELEASE_NOW,
value: ReleaseDateType.RELEASE_NOW,
disabled: false
},
{
label: ReleaseDateType.SCHEDULED_RELEASE,
value: ReleaseDateType.SCHEDULED_RELEASE,
disabled: false
}
].filter(removeNullable)

export const ScheduledReleaseRadioField = (props) => {
const { selected } = props
const isInitiallyUnlisted = props.route.params.isInitiallyUnlisted
const { selected, isInitiallyUnlisted } = props
const { primary } = useThemeColors()
const styles = useStyles()
const theme = useThemeVariant()
Expand Down Expand Up @@ -243,7 +229,7 @@ export const ScheduledReleaseRadioField = (props) => {
}

export const ReleaseNowRadioField = (props) => {
const { selected } = props
const { selected, isInitiallyUnlisted } = props
const [{ value: releaseDateValue }, , { setValue: setReleaseDateValue }] =
useField<Nullable<string>>('release_date')
const styles = useStyles()
Expand All @@ -268,7 +254,12 @@ export const ReleaseNowRadioField = (props) => {

return (
<View style={styles.releaseNowContainer}>
<Text size='l' strength='strong' variant='body'>
<Text
size='l'
strength='strong'
variant='body'
color={!isInitiallyUnlisted ? 'subdued' : undefined}
>
{messages.releaseNowRadio}
</Text>
{selected ? (
Expand All @@ -284,6 +275,7 @@ export const ReleaseNowRadioField = (props) => {
}

export const ReleaseDateScreen = (props) => {
const isInitiallyUnlisted = props.route.params.isInitiallyUnlisted
const [{ value }] = useField<Nullable<string>>('release_date')

const [releaseDateType, setReleaseDateType] = useState<ReleaseDateType>(
Expand All @@ -296,12 +288,13 @@ export const ReleaseDateScreen = (props) => {
[ReleaseDateType.RELEASE_NOW]: (
<ReleaseNowRadioField
selected={releaseDateType === ReleaseDateType.RELEASE_NOW}
isInitiallyUnlisted={isInitiallyUnlisted}
/>
),
[ReleaseDateType.SCHEDULED_RELEASE]: (
<ScheduledReleaseRadioField
selected={releaseDateType === ReleaseDateType.SCHEDULED_RELEASE}
{...props}
isInitiallyUnlisted={isInitiallyUnlisted}
/>
)
}
Expand All @@ -312,6 +305,18 @@ export const ReleaseDateScreen = (props) => {
navigation.goBack()
dispatch(reset())
}, [navigation, dispatch])
const data: ListSelectionData[] = [
{
label: ReleaseDateType.RELEASE_NOW,
value: ReleaseDateType.RELEASE_NOW,
disabled: !isInitiallyUnlisted
},
{
label: ReleaseDateType.SCHEDULED_RELEASE,
value: ReleaseDateType.SCHEDULED_RELEASE,
disabled: false
}
].filter(removeNullable)

return (
<ListSelectionScreen
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/data-entry/FormTile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ const AdvancedForm = (props) => {
const didUpdateReleaseDate = (newState) => {
props.onChangeField('release_date', newState.release_date)
props.onChangeField('is_unlisted', newState.is_unlisted)
props.onChangeField('is_scheduled_release', newState.is_unlisted)
}

const didToggleHideRemixesState = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ export const ReleaseDateTriggerLegacy = (
newState.is_unlisted = false
} else {
newState.is_unlisted = true
newState.is_scheduled_release = true
}
props.initialForm.release_date = newState.release_date

setTrackReleaseDateState(newState.release_date)
setTrackReleaseDateState(newState.release_date)
didUpdateState(newState)
}
Expand All @@ -114,6 +117,7 @@ export const ReleaseDateTriggerLegacy = (
<Text>{messages.description}</Text>
<ReleaseDateRadioItems
isInitiallyUnlisted={props.initialForm.is_unlisted}
initialReleaseDate={trackReleaseDateState}
/>
</Flex>
</>
Expand Down
3 changes: 1 addition & 2 deletions packages/web/src/components/share-modal/ShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ export const ShareModal = () => {
),
shareType: content?.type ?? 'track',
isPrivate:
content?.type === 'playlist' ? content.playlist.is_private : false,
isUnlisted: content?.type === 'track' ? content.track.is_unlisted : false
content?.type === 'playlist' ? content.playlist.is_private : false
}

if (isMobile()) return <ShareDrawer {...shareProps} />
Expand Down
19 changes: 8 additions & 11 deletions packages/web/src/components/share-modal/components/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export const ShareDialog = ({
onClosed,
showTikTokShareAction,
shareType,
isPrivate,
isUnlisted
isPrivate
}: ShareDialogProps) => {
return (
<Modal
Expand Down Expand Up @@ -86,15 +85,13 @@ export const ShareDialog = ({
iconClassName={styles.shareIcon}
textClassName={styles.shareActionLabel}
/>
{!isUnlisted ? (
<ShareActionListItem
leftIcon={<IconTwitterBird {...iconProps} />}
text={messages.twitter}
onClick={onShareToTwitter}
iconClassName={styles.shareIcon}
textClassName={styles.shareActionLabel}
/>
) : null}
<ShareActionListItem
leftIcon={<IconTwitterBird {...iconProps} />}
text={messages.twitter}
onClick={onShareToTwitter}
iconClassName={styles.shareIcon}
textClassName={styles.shareActionLabel}
/>
{showTikTokShareAction ? (
<ShareActionListItem
leftIcon={<IconTikTok {...iconProps} />}
Expand Down
1 change: 0 additions & 1 deletion packages/web/src/components/share-modal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export type ShareProps = {
showTikTokShareAction?: boolean
shareType: ShareType
isPrivate: boolean
isUnlisted: boolean
}
22 changes: 20 additions & 2 deletions packages/web/src/components/track/GiantTrackTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
PremiumConditions,
FieldVisibility,
getDogEarType,
isPremiumContentUSDCPurchaseGated
isPremiumContentUSDCPurchaseGated,
publishTrackConfirmationModalUIActions
} from '@audius/common'
import { Flex } from '@audius/harmony'
import { Mood } from '@audius/sdk'
Expand All @@ -28,6 +29,7 @@ import {
} from '@audius/stems'
import cn from 'classnames'
import moment from 'moment'
import { useDispatch } from 'react-redux'

import IconRobot from 'assets/img/robot.svg'
import DownloadButtons from 'components/download-buttons/DownloadButtons'
Expand Down Expand Up @@ -58,6 +60,9 @@ import InfoLabel from './InfoLabel'
import { PlayPauseButton } from './PlayPauseButton'
import { PremiumTrackSection } from './PremiumTrackSection'

const { requestOpen: openPublishTrackConfirmationModal } =
publishTrackConfirmationModalUIActions

const BUTTON_COLLAPSE_WIDTHS = {
first: 1095,
second: 1190,
Expand Down Expand Up @@ -176,6 +181,7 @@ export const GiantTrackTile = ({
trackTitle,
userId
}: GiantTrackTileProps) => {
const dispatch = useDispatch()
const [artworkLoading, setArtworkLoading] = useState(true)
const onArtworkLoad = useCallback(
() => setArtworkLoading(false),
Expand Down Expand Up @@ -249,7 +255,19 @@ export const GiantTrackTile = ({
)
}
widthToHideText={BUTTON_COLLAPSE_WIDTHS.second}
onClick={isPublishing ? undefined : () => onMakePublic(trackId)}
onClick={
isPublishing
? undefined
: () => {
dispatch(
openPublishTrackConfirmationModal({
confirmCallback: () => {
onMakePublic(trackId)
}
})
)
}
}
/>
)
)
Expand Down
53 changes: 28 additions & 25 deletions packages/web/src/pages/upload-page/components/ShareBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ const messages = {

type ShareBannerProps = {
user: User
isUnlistedTrack: boolean
}

export const ShareBanner = (props: ShareBannerProps) => {
const { user } = props
const { user, isUnlistedTrack } = props
const dispatch = useDispatch()
const { toast } = useContext(ToastContext)
const record = useRecord()
Expand Down Expand Up @@ -66,30 +67,32 @@ export const ShareBanner = (props: ShareBannerProps) => {
<Text variant='heading' size='medium' color='darkmodeStaticWhite'>
{messages.shareText}
</Text>
<div className={styles.buttonContainer}>
<Button
fullWidth
leftIcon={<IconTwitterBird />}
onClick={handleTwitterShare}
text={
<Text variant='title' size='large' color='secondary'>
{messages.twitterButtonText}
</Text>
}
type={ButtonType.WHITE}
/>
<Button
fullWidth
leftIcon={<IconLink />}
onClick={handleCopyTrackLink}
text={
<Text variant='title' size='large' color='secondary'>
{messages.copyLinkButtonText}
</Text>
}
type={ButtonType.WHITE}
/>
</div>
{!isUnlistedTrack ? (
<div className={styles.buttonContainer}>
<Button
fullWidth
leftIcon={<IconTwitterBird />}
onClick={handleTwitterShare}
text={
<Text variant='title' size='large' color='secondary'>
{messages.twitterButtonText}
</Text>
}
type={ButtonType.WHITE}
/>
<Button
fullWidth
leftIcon={<IconLink />}
onClick={handleCopyTrackLink}
text={
<Text variant='title' size='large' color='secondary'>
{messages.copyLinkButtonText}
</Text>
}
type={ButtonType.WHITE}
/>
</div>
) : null}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ export const AccessAndSaleMenuFields = (props: AccesAndSaleMenuFieldsProps) => {
value={TrackAvailabilityType.HIDDEN}
description={messages.hiddenSubtitle}
disabled={noHidden}
hintContent={isScheduledRelease ? messages.hiddenHint : ''}
hintContent={
isScheduledRelease && isInitiallyUnlisted ? messages.hiddenHint : ''
}
checkedContent={<HiddenAvailabilityFields />}
/>
</RadioButtonGroup>
Expand Down
Loading