Skip to content

Commit 011438a

Browse files
authored
[PE-5994] Fix mobile lineups (#11905)
1 parent 36e6f5d commit 011438a

File tree

3 files changed

+47
-30
lines changed

3 files changed

+47
-30
lines changed

packages/mobile/src/components/lineup/TanQueryLineup.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export type LineupProps = {
298298
itemStyles?: ViewStyle
299299

300300
// Tan query props
301-
pageSize?: number
301+
pageSize: number
302302
initialPageSize?: number
303303
isFetching: boolean
304304
loadNextPage: () => void
@@ -318,7 +318,6 @@ export type LineupProps = {
318318
*/
319319
export const TanQueryLineup = ({
320320
actions,
321-
maxEntries,
322321
delineate,
323322
disableTopTabScroll,
324323
fetchPayload,
@@ -350,6 +349,7 @@ export const TanQueryLineup = ({
350349
isFetching,
351350
isPending,
352351
queryData = [],
352+
maxEntries = Infinity,
353353
...listProps
354354
}: LineupProps) => {
355355
const debouncedLoadNextPage = useDebouncedCallback(
@@ -429,16 +429,11 @@ export const TanQueryLineup = ({
429429
: entries.slice(offset)
430430

431431
const getSkeletonCount = () => {
432-
// No skeletons if not fetching
433-
if (!isFetching && !isLineupPending) {
434-
return 0
432+
if (lineup.entries.length === 0 && (isPending || isLineupPending)) {
433+
return Math.min(maxEntries, initialPageSize ?? pageSize)
435434
}
436-
// Lineups like Feed load a different number of items on the first page
437-
if (initialPageSize && isPending) {
438-
return initialPageSize
439-
}
440-
if (pageSize) {
441-
return maxEntries ? Math.min(maxEntries, pageSize) : pageSize
435+
if (isFetching) {
436+
return Math.min(maxEntries, pageSize)
442437
}
443438
return 0
444439
}

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { trackPageMessages as messages } from '@audius/common/messages'
33
import type { ID, User } from '@audius/common/models'
44
import { tracksActions } from '~/store/pages/track/lineup/actions'
55

6-
import { Button, Flex, Text } from '@audius/harmony-native'
6+
import { Flex, Text } from '@audius/harmony-native'
77
import { TanQueryLineup } from 'app/components/lineup/TanQueryLineup'
8-
import { useNavigation } from 'app/hooks/useNavigation'
8+
9+
import { ViewOtherRemixesButton } from './ViewOtherRemixesButton'
910

1011
type TrackScreenLineupProps = {
1112
user: User | null
@@ -46,25 +47,13 @@ export const TrackScreenLineup = ({
4647
data
4748
} = useTrackPageLineup({ trackId })
4849

49-
const navigation = useNavigation()
50-
51-
const viewRemixesButton = (
52-
<Button
53-
style={{ alignSelf: 'flex-start' }}
54-
size='small'
55-
onPress={() => {
56-
navigation.navigate('TrackRemixes', { trackId })
57-
}}
58-
>
59-
{messages.viewOtherRemixes}
60-
</Button>
61-
)
62-
6350
if (!indices) return null
6451

6552
const renderRemixParentSection = () => {
6653
if (indices.remixParentSection.index === undefined) return null
6754

55+
const parentTrackId = data?.[indices.remixParentSection.index]?.id
56+
6857
return (
6958
<Section title={messages.originalTrack}>
7059
<Flex column gap='l'>
@@ -73,6 +62,7 @@ export const TrackScreenLineup = ({
7362
lineup={lineup}
7463
offset={indices.remixParentSection.index}
7564
maxEntries={indices.remixParentSection.pageSize}
65+
pageSize={pageSize}
7666
includeLineupStatus
7767
itemStyles={itemStyles}
7868
isFetching={isFetching}
@@ -81,14 +71,16 @@ export const TrackScreenLineup = ({
8171
isPending={isPending}
8272
queryData={data}
8373
/>
84-
{viewRemixesButton}
74+
{parentTrackId ? (
75+
<ViewOtherRemixesButton parentTrackId={parentTrackId} />
76+
) : null}
8577
</Flex>
8678
</Section>
8779
)
8880
}
8981

9082
const renderRemixesSection = () => {
91-
if (indices.remixesSection.index === null) return null
83+
if (indices.remixesSection.index === undefined) return null
9284

9385
return (
9486
<Section title={messages.remixes}>
@@ -98,6 +90,7 @@ export const TrackScreenLineup = ({
9890
lineup={lineup}
9991
offset={indices.remixesSection.index}
10092
maxEntries={indices.remixesSection.pageSize}
93+
pageSize={pageSize}
10194
includeLineupStatus
10295
itemStyles={itemStyles}
10396
isFetching={isFetching}
@@ -106,7 +99,7 @@ export const TrackScreenLineup = ({
10699
isPending={isPending}
107100
queryData={data}
108101
/>
109-
{viewRemixesButton}
102+
<ViewOtherRemixesButton parentTrackId={trackId} />
110103
</Flex>
111104
</Section>
112105
)
@@ -122,6 +115,7 @@ export const TrackScreenLineup = ({
122115
lineup={lineup}
123116
offset={indices.moreBySection.index}
124117
maxEntries={indices.moreBySection.pageSize ?? pageSize}
118+
pageSize={pageSize}
125119
includeLineupStatus
126120
itemStyles={itemStyles}
127121
isFetching={isFetching}
@@ -144,6 +138,7 @@ export const TrackScreenLineup = ({
144138
lineup={lineup}
145139
offset={indices.recommendedSection.index}
146140
maxEntries={indices.recommendedSection.pageSize}
141+
pageSize={pageSize}
147142
includeLineupStatus
148143
itemStyles={itemStyles}
149144
isFetching={isFetching}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { trackPageMessages as messages } from '@audius/common/messages'
2+
import type { ID } from '@audius/common/models'
3+
4+
import { Button } from '@audius/harmony-native'
5+
import { useNavigation } from 'app/hooks/useNavigation'
6+
7+
type ViewOtherRemixesButtonProps = {
8+
parentTrackId: ID
9+
}
10+
11+
export const ViewOtherRemixesButton = ({
12+
parentTrackId: trackId
13+
}: ViewOtherRemixesButtonProps) => {
14+
const navigation = useNavigation()
15+
16+
return (
17+
<Button
18+
style={{ alignSelf: 'flex-start' }}
19+
size='small'
20+
onPress={() => {
21+
navigation.navigate('TrackRemixes', { trackId })
22+
}}
23+
>
24+
{messages.viewOtherRemixes}
25+
</Button>
26+
)
27+
}

0 commit comments

Comments
 (0)