Skip to content

Commit 810923f

Browse files
authored
Fix remix contest submissions (#13821)
Fixes remix contest page, adding filters back for web, mobile-web, and mobile
1 parent 6af896b commit 810923f

8 files changed

Lines changed: 347 additions & 478 deletions

File tree

packages/mobile/src/harmony-native/components/Button/FilterButton/FilterButton.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const FilterButton = <Value extends string>(
3030
onChange,
3131
filterScreen = 'FilterButton',
3232
options,
33-
screen
33+
screen,
34+
disableSearch
3435
} = props
3536

3637
const selectedOption = options?.find((option) => option.value === value)
@@ -113,11 +114,22 @@ export const FilterButton = <Value extends string>(
113114
title: label,
114115
onChange,
115116
value,
116-
screen
117+
screen,
118+
disableSearch
117119
})
118120
}
119121
},
120-
[onPress, options, screen, navigation, filterScreen, label, onChange, value]
122+
[
123+
onPress,
124+
options,
125+
screen,
126+
navigation,
127+
filterScreen,
128+
label,
129+
onChange,
130+
value,
131+
disableSearch
132+
]
121133
)
122134

123135
const Icon = useMemo(() => {

packages/mobile/src/harmony-native/components/Button/FilterButton/FilterButtonScreen.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type FilterButtonScreenParams = {
1515
onChange: (value: Maybe<string>) => void
1616
value: string
1717
screen?: ComponentType<ScreenProps<string>>
18+
disableSearch?: boolean
1819
}
1920

2021
export const FilterButtonScreen = () => {
@@ -24,7 +25,8 @@ export const FilterButtonScreen = () => {
2425
title,
2526
onChange: onSubmit,
2627
value: initialValue,
27-
screen: Screen
28+
screen: Screen,
29+
disableSearch = false
2830
} = params ?? {}
2931

3032
const [value, setValue] = useState<Maybe<string>>(initialValue)
@@ -47,6 +49,7 @@ export const FilterButtonScreen = () => {
4749
value={value ?? ''}
4850
onSubmit={handleSubmit}
4951
searchText={`Search ${title}`}
52+
disableSearch={disableSearch}
5053
clearable={Boolean(value)}
5154
onClear={() => setValue(undefined)}
5255
/>

packages/mobile/src/harmony-native/components/Button/FilterButton/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,9 @@ export type FilterButtonProps<Value extends string = string> = {
129129
*/
130130
screen?: ComponentType<ScreenProps<Value>>
131131
renderLabel?: (label: string) => ReactNode
132+
133+
/**
134+
* When true, the list selection screen will not show a search field (e.g. for short option lists)
135+
*/
136+
disableSearch?: boolean
132137
}

packages/mobile/src/screens/track-screen/TrackRemixesScreen.tsx

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useCallback, useState } from 'react'
2+
13
import {
24
useCurrentUserId,
35
useRemixContest,
@@ -12,6 +14,7 @@ import { Text as RNText, View } from 'react-native'
1214

1315
import {
1416
Button,
17+
FilterButton,
1518
Flex,
1619
IconRemix,
1720
IconTrophy,
@@ -56,17 +59,37 @@ const useStyles = makeStyles(({ spacing, palette, typography }) => ({
5659
}
5760
}))
5861

62+
const SORT_OPTIONS = [
63+
{ label: 'Most Recent', value: 'recent' as const },
64+
{ label: 'Most Plays', value: 'plays' as const },
65+
{ label: 'Most Favorites', value: 'likes' as const }
66+
]
67+
5968
export const TrackRemixesScreen = () => {
6069
const { onOpen: openPickWinnersDrawer } = useDrawer('PickWinners')
6170
const { data: currentUserId } = useCurrentUserId()
6271
const { params } = useRoute<'TrackRemixes'>()
6372
const { data: track } = useTrackByParams(params)
6473
const trackId = track?.track_id
74+
75+
const [sortMethod, setSortMethod] = useState<'recent' | 'plays' | 'likes'>(
76+
'recent'
77+
)
78+
const [isCosign, setIsCosign] = useState(false)
79+
const [isContestEntry, setIsContestEntry] = useState(false)
80+
81+
const handleSortChange = useCallback((value: string | undefined) => {
82+
setSortMethod((value as 'recent' | 'plays' | 'likes') ?? 'recent')
83+
}, [])
84+
6585
const { data, count, isFetching, isPending, loadNextPage, lineup, pageSize } =
6686
useRemixesLineup({
6787
trackId: track?.track_id,
6888
includeOriginal: true,
69-
includeWinners: true
89+
includeWinners: true,
90+
sortMethod,
91+
isCosign,
92+
isContestEntry
7093
})
7194
const { data: contest } = useRemixContest(trackId)
7295
const isRemixContest = !!contest
@@ -94,13 +117,40 @@ export const TrackRemixesScreen = () => {
94117
)
95118

96119
const remixesDelineator = (
97-
<Flex justifyContent='space-between' ph='l' pt='xl'>
120+
<Flex ph='l' pt='xl' gap='m'>
98121
{count ? (
99122
<Text variant='title'>
100123
{messages.remixesTitle}
101124
{count !== undefined ? ` (${count})` : ''}
102125
</Text>
103126
) : null}
127+
<Flex row gap='s' wrap='wrap'>
128+
<FilterButton
129+
label={messages.coSigned}
130+
value={isCosign ? 'true' : undefined}
131+
onPress={() => setIsCosign((prev) => !prev)}
132+
onChange={(v) => setIsCosign(v === 'true')}
133+
size='small'
134+
/>
135+
{isRemixContest ? (
136+
<FilterButton
137+
label={messages.contestEntries}
138+
value={isContestEntry ? 'true' : undefined}
139+
onPress={() => setIsContestEntry((prev) => !prev)}
140+
onChange={(v) => setIsContestEntry(v === 'true')}
141+
size='small'
142+
/>
143+
) : null}
144+
<FilterButton
145+
label='Sort'
146+
value={sortMethod}
147+
variant='replaceLabel'
148+
onChange={handleSortChange}
149+
options={SORT_OPTIONS}
150+
disableSearch
151+
size='small'
152+
/>
153+
</Flex>
104154
</Flex>
105155
)
106156

packages/web/src/pages/remixes-page/components/desktop/NewRemixesPage.tsx

Lines changed: 0 additions & 208 deletions
This file was deleted.

0 commit comments

Comments
 (0)