Skip to content

Commit

Permalink
Fix broken track upload for electronic subgenres on mobile (#3835)
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 Aug 1, 2023
1 parent f643695 commit 6337949
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
9 changes: 6 additions & 3 deletions packages/common/src/utils/genres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const getCanonicalName = (genre: Genre | any) => {
return genre
}

/** User-facing genre labels. Use `convertGenreLabelToValue` to get the correct genre value (to set as the genre in track metadata). */
export const GENRES = [
Genre.ELECTRONIC,
Genre.ROCK,
Expand Down Expand Up @@ -115,11 +116,13 @@ export const GENRES = [
Genre.LATIN,
Genre.LOFI,
Genre.HYPERPOP,
...Object.keys(ELECTRONIC_SUBGENRES).map(
(subgenre) => `${ELECTRONIC_PREFIX}${subgenre}`
)
...Object.values(ELECTRONIC_SUBGENRES)
]

export const convertGenreLabelToValue = (genreLabel: typeof GENRES[number]) => {
return genreLabel.replace(ELECTRONIC_PREFIX, '')
}

const NEWLY_ADDED_GENRES: string[] = []

export const TRENDING_GENRES = GENRES.filter(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GENRES } from '@audius/common'
import { convertGenreLabelToValue, GENRES } from '@audius/common'
import { useField } from 'formik'

import IconGenre from 'app/assets/images/iconGenre.svg'
Expand All @@ -11,7 +11,10 @@ const messages = {
searchText: 'Select Genres'
}

const genres = GENRES.map((genre) => ({ value: genre, label: genre }))
const genres = GENRES.map((genre) => ({
value: convertGenreLabelToValue(genre),
label: genre
}))

export const SelectGenreScreen = () => {
const [{ value }, , { setValue }] = useField('genre')
Expand Down
7 changes: 2 additions & 5 deletions packages/web/src/components/data-entry/FormTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, useState, useCallback } from 'react'

import {
GENRES,
ELECTRONIC_PREFIX,
convertGenreLabelToValue,
getCanonicalName,
createRemixOfMetadata,
creativeCommons,
Expand Down Expand Up @@ -252,10 +252,7 @@ const BasicForm = (props) => {
isRequired={props.requiredFields.genre}
error={props.invalidFields.genre}
onSelect={(value) =>
props.onChangeField(
'genre',
value.replace(ELECTRONIC_PREFIX, '')
)
props.onChangeField('genre', convertGenreLabelToValue(value))
}
size='large'
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const TrackMetadataFields = (props: TrackMetadataFieldsProps) => {
aria-label={messages.genre}
placeholder={messages.genre}
mount='parent'
// TODO: Use correct value for Genres based on label (see `convertGenreLabelToValue`)
menu={{ items: GENRES }}
size='large'
/>
Expand Down

0 comments on commit 6337949

Please sign in to comment.