Skip to content

Commit

Permalink
[C-2556, C-2557] Address AI Attribution QA (#3349)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed May 16, 2023
1 parent 1a1ab73 commit 8cc9225
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import UserBadges from 'app/components/user-badges'
import { useNavigation } from 'app/hooks/useNavigation'
import { useProfileRoute } from 'app/hooks/useRoute'
import { makeStyles } from 'app/styles'
import { spacing } from 'app/styles/spacing'

import { ShareAiTracksTile } from './ShareAiTracksTile'

Expand All @@ -30,16 +31,20 @@ const messages = {
headerText: 'Tracks generated with AI trained on music by '
}

const iconSize = { height: spacing(6), width: spacing(6) }

const useStyles = makeStyles(({ spacing, palette, typography }) => ({
headerTextContainer: {
alignItems: 'center',
header: {
flexDirection: 'row',
flexWrap: 'wrap',
paddingHorizontal: spacing(7),
paddingVertical: spacing(3),
backgroundColor: palette.white
},
headerText: {
fontSize: typography.fontSize.medium,
lineHeight: typography.fontSize.medium * 1.3
lineHeight: typography.fontSize.medium * 1.3,
textAlign: 'left'
},
userBadgeTitle: {
fontSize: typography.fontSize.medium,
Expand Down Expand Up @@ -94,12 +99,16 @@ export const AiGeneratedTracksScreen = () => {

return (
<Screen>
<ScreenHeader text={messages.header} icon={IconRobot} />
<ScreenHeader
text={messages.header}
icon={IconRobot}
iconProps={iconSize}
/>
<ScreenContent>
<Lineup
header={
user ? (
<View style={styles.headerTextContainer}>
<View style={styles.header}>
<Text>{messages.headerText}</Text>
<TouchableOpacity onPress={handleGoToProfile}>
<UserBadges user={user} nameStyle={styles.userBadgeTitle} />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import { FeatureFlags, accountSelectors } from '@audius/common'
import { View } from 'react-native'
import { useSelector } from 'react-redux'

import IconTip from 'app/assets/images/iconTip.svg'
import { Divider, Text } from 'app/components/core'
import { useFeatureFlag } from 'app/hooks/useRemoteConfig'
import { makeStyles } from 'app/styles'
import { useThemeColors } from 'app/utils/theme'

import { useSelectProfile } from '../selectors'

import { AiGeneratedTracksButton } from './AiGeneratedTracksButton'
import { Bio } from './Bio'
import { ProfileMutualsButton } from './ProfileMutualsButton'
import { ProfileRelatedArtistsButton } from './ProfileRelatedArtistsButton'
import { ProfileInfoTiles } from './ProfileInfoTiles'
import { ProfileTierTile } from './ProfileTierTile'
import { SocialsAndSites } from './SocialsAndSites'
import { SupportingList } from './SupportingList'
const getUserId = accountSelectors.getUserId

const messages = {
supporting: 'Supporting'
Expand Down Expand Up @@ -68,39 +62,14 @@ const SupportingSectionTitle = () => {

export const ExpandedSection = () => {
const styles = useStyles()
const {
supporting_count,
user_id,
current_user_followee_follow_count,
allow_ai_attribution
} = useSelectProfile([
'supporting_count',
'user_id',
'current_user_followee_follow_count',
'allow_ai_attribution'
])

const { isEnabled: isAiGeneratedTracksEnabled } = useFeatureFlag(
FeatureFlags.AI_ATTRIBUTION
)

const accountId = useSelector(getUserId)
const isOwner = user_id === accountId
const { supporting_count } = useSelectProfile(['supporting_count'])

return (
<View pointerEvents='box-none'>
<Bio />
<ProfileTierTile interactive={false} style={styles.audioTier} />
<SocialsAndSites />
<View style={styles.buttonRow}>
{allow_ai_attribution && isAiGeneratedTracksEnabled ? (
<AiGeneratedTracksButton />
) : null}
{isOwner || current_user_followee_follow_count === 0 ? null : (
<ProfileMutualsButton />
)}
<ProfileRelatedArtistsButton />
</View>
<ProfileInfoTiles />
{supporting_count > 0 ? (
<>
<SupportingSectionTitle />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const ProfileHeader = memo((props: ProfileHeaderProps) => {
'supporting_count',
'allow_ai_attribution'
])

const { tier = 'none' } = useSelectTierInfo(userId)
const hasTier = tier !== 'none'
const isOwner = userId === accountId
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import type { ComponentType } from 'react'
import { useCallback } from 'react'

import {
FeatureFlags,
accountSelectors,
relatedArtistsUISelectors
} from '@audius/common'
import type { ViewStyle } from 'react-native'
import { View, ScrollView } from 'react-native'
import { useSelector } from 'react-redux'

import IconFollowing from 'app/assets/images/iconFollowing.svg'
import IconRobot from 'app/assets/images/iconRobot.svg'
import IconUserGroup from 'app/assets/images/iconUserGroup.svg'
import { Text, Tile } from 'app/components/core'
import { useNavigation } from 'app/hooks/useNavigation'
import { useFeatureFlag } from 'app/hooks/useRemoteConfig'
import { makeStyles } from 'app/styles'
import type { SvgProps } from 'app/types/svg'
import { useThemePalette } from 'app/utils/theme'

import { useSelectProfile } from '../selectors'

const { getUserId } = accountSelectors
const { selectRelatedArtistsById } = relatedArtistsUISelectors

const useInfoTileStyles = makeStyles(({ spacing }) => ({
root: { flexGrow: 1 },
tile: { height: 50 },
content: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
icon: {
marginRight: spacing(2)
}
}))

const messages = {
aiGeneratedTracks: 'AI Generated Tracks',
mutuals: 'Mutuals',
relatedArtists: 'Related Artists'
}

type ProfileInfoTileProps = {
style?: ViewStyle
screen: string
icon: ComponentType<SvgProps>
text: string
}

const ProfileInfoTile = (props: ProfileInfoTileProps) => {
const { style, screen, icon: Icon, text } = props
const styles = useInfoTileStyles()
const { neutral } = useThemePalette()
const navigation = useNavigation()
const { user_id } = useSelectProfile(['user_id'])

const handlePress = useCallback(() => {
navigation.navigate(screen, { userId: user_id })
}, [navigation, screen, user_id])

return (
<Tile
styles={{
root: [styles.root, style],
tile: styles.tile,
content: styles.content
}}
onPress={handlePress}
>
<Icon height={20} width={20} fill={neutral} style={styles.icon} />
<Text variant='h3' noGutter>
{text}
</Text>
</Tile>
)
}

type TileProps = {
style?: ViewStyle
}

const AiGeneratedTracksTile = (props: TileProps) => {
return (
<ProfileInfoTile
screen='AiGeneratedTracks'
icon={IconRobot}
text={messages.aiGeneratedTracks}
{...props}
/>
)
}

const MutualsTile = (props: TileProps) => {
return (
<ProfileInfoTile
screen='Mutuals'
icon={IconFollowing}
text={messages.mutuals}
{...props}
/>
)
}

const RelatedArtistsTile = (props: TileProps) => {
return (
<ProfileInfoTile
screen='RelatedArtists'
icon={IconUserGroup}
text={messages.relatedArtists}
{...props}
/>
)
}

const useStyles = makeStyles(({ spacing }) => ({
rootScrollView: {
marginHorizontal: spacing(-3)
},
rootScrollViewContent: {
gap: spacing(2),
paddingVertical: spacing(2),
paddingHorizontal: spacing(3)
},
rootView: {
flexDirection: 'row',
marginVertical: spacing(2),
gap: spacing(2)
},
scrollableTile: {
width: 200
}
}))

export const ProfileInfoTiles = () => {
const styles = useStyles()
const { user_id, current_user_followee_follow_count, allow_ai_attribution } =
useSelectProfile([
'supporting_count',
'user_id',
'current_user_followee_follow_count',
'allow_ai_attribution'
])

const { isEnabled: isAiGeneratedTracksEnabled } = useFeatureFlag(
FeatureFlags.AI_ATTRIBUTION
)

const accountId = useSelector(getUserId)

const hasAiAttribution = allow_ai_attribution && isAiGeneratedTracksEnabled

const hasMutuals =
user_id !== accountId && current_user_followee_follow_count > 0

const hasRelatedArtists = useSelector((state) => {
const relatedArtists = selectRelatedArtistsById(state, user_id)
if (!relatedArtists) return false
const { relatedArtistIds, isTopArtistsRecommendation } = relatedArtists
if (isTopArtistsRecommendation) return false
return relatedArtistIds.length > 0
})

const hasAllThreeTiles = hasAiAttribution && hasMutuals && hasRelatedArtists

if (hasAllThreeTiles) {
return (
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
style={styles.rootScrollView}
contentContainerStyle={styles.rootScrollViewContent}
>
<AiGeneratedTracksTile style={styles.scrollableTile} />
<MutualsTile style={styles.scrollableTile} />
<RelatedArtistsTile style={styles.scrollableTile} />
</ScrollView>
)
}

return (
<View style={styles.rootView}>
{hasAiAttribution ? <AiGeneratedTracksTile /> : null}
{hasMutuals ? <MutualsTile /> : null}
{hasRelatedArtists ? <RelatedArtistsTile /> : null}
</View>
)
}
Loading

0 comments on commit 8cc9225

Please sign in to comment.