Skip to content

Commit 2b2124e

Browse files
authored
[QA-1979] Fix now playing UI in collection pages (#11408)
1 parent 33416eb commit 2b2124e

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

packages/web/src/components/collectibles-playlist-table/CollectiblesPlaylistTable.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type CollectiblesPlaylistTableProps = {
3838
onClickRow?: (collectible: any, index: number) => void
3939
onClickTrackName?: (collectible: any) => void
4040
playing?: boolean
41-
playingIndex?: number
41+
activeIndex?: number
4242
tableClassName?: string
4343
wrapperClassName?: string
4444
}
@@ -59,15 +59,15 @@ export const CollectiblesPlaylistTable = ({
5959
onClickRow,
6060
onClickTrackName: onClickCollectibleName,
6161
playing = false,
62-
playingIndex = -1,
62+
activeIndex = -1,
6363
tableClassName,
6464
wrapperClassName
6565
}: CollectiblesPlaylistTableProps) => {
6666
// Cell Render Functions
6767
const renderPlayButtonCell = useCallback(
6868
(cellInfo: CollectibleCell) => {
6969
const index = cellInfo.row.index
70-
const active = index === playingIndex
70+
const active = index === activeIndex
7171
return (
7272
<TablePlayButton
7373
className={cn(styles.tablePlayButton, { [styles.active]: active })}
@@ -77,7 +77,7 @@ export const CollectiblesPlaylistTable = ({
7777
/>
7878
)
7979
},
80-
[playing, playingIndex]
80+
[playing, activeIndex]
8181
)
8282

8383
const renderCollectibleNameCell = useCallback(
@@ -94,15 +94,15 @@ export const CollectiblesPlaylistTable = ({
9494
>
9595
<div
9696
className={cn(styles.textCell, styles.collectibleName, {
97-
[styles.isPlaying]: index === playingIndex
97+
[styles.isPlaying]: index === activeIndex
9898
})}
9999
>
100100
{collectible.name}
101101
</div>
102102
</div>
103103
)
104104
},
105-
[onClickCollectibleName, playingIndex]
105+
[onClickCollectibleName, activeIndex]
106106
)
107107

108108
const renderLengthCell = useCallback((cellInfo: CollectibleCell) => {
@@ -198,7 +198,7 @@ export const CollectiblesPlaylistTable = ({
198198
data={data}
199199
loading={loading}
200200
onClickRow={handleClickRow}
201-
activeIndex={playingIndex}
201+
activeIndex={activeIndex}
202202
isVirtualized={isVirtualized}
203203
/>
204204
)

packages/web/src/components/tracks-table/TrackTableLineup.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ export const TrackTableLineup = ({
8484
: (lineup.entries as LineupTrack[])
8585
}, [lineup.entries, tracks, hasNextPage, pageSize])
8686

87-
// Get the playing index by finding the current track in the data
88-
const playingIndex = useMemo(() => {
87+
// Get the active index by finding the current track in the data
88+
const activeIndex = useMemo(() => {
8989
if (!currentQueueItem?.uid) return -1
9090
return entries.findIndex((track) => track.uid === currentQueueItem.uid)
9191
}, [currentQueueItem?.uid, entries])
@@ -124,7 +124,7 @@ export const TrackTableLineup = ({
124124

125125
const onClickRow = useCallback(
126126
(track: TrackWithUID, index: number) => {
127-
if (index === playingIndex && isPlaying) {
127+
if (index === activeIndex && isPlaying) {
128128
pause()
129129
dispatch(
130130
make(Name.PLAYBACK_PAUSE, {
@@ -142,7 +142,7 @@ export const TrackTableLineup = ({
142142
)
143143
}
144144
},
145-
[dispatch, isPlaying, pause, play, playingSource, playingIndex, entries]
145+
[dispatch, isPlaying, pause, play, playingSource, activeIndex, entries]
146146
)
147147

148148
return (
@@ -152,7 +152,7 @@ export const TrackTableLineup = ({
152152
onClickFavorite={onClickFavorite}
153153
onClickRepost={onClickRepost}
154154
playing={isPlaying && !isBuffering}
155-
activeIndex={playingIndex}
155+
activeIndex={activeIndex}
156156
onClickRow={onClickRow}
157157
fetchMore={loadNextPage}
158158
loading={isInitialLoading}

packages/web/src/pages/collectibles-playlist-page/CollectiblesPlaylistPageProvider.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@ export const CollectiblesPlaylistPageProvider = ({
360360
const getFilteredData = useCallback(
361361
(trackMetadatas: CollectionTrack[]) => {
362362
const playingUid = getPlayingUid()
363-
const playingIndex = entries.findIndex(({ uid }) => uid === playingUid)
363+
const activeIndex = entries.findIndex(({ uid }) => uid === playingUid)
364364
const formattedMetadata = formatMetadata(trackMetadatas)
365365
const filteredIndex =
366-
playingIndex > -1
366+
activeIndex > -1
367367
? formattedMetadata.findIndex(
368368
(metadata) => metadata.uid === playingUid
369369
)
370-
: playingIndex
370+
: activeIndex
371371
return [formattedMetadata, filteredIndex] as [
372372
typeof formattedMetadata,
373373
number

packages/web/src/pages/collection-page/CollectionPageProvider.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ class CollectionPage extends Component<
444444
const filterText = this.state.filterText
445445
const { tracks } = this.props
446446
const playingUid = this.getPlayingUid()
447-
const playingIndex = tracks.entries.findIndex(
447+
const activeIndex = tracks.entries.findIndex(
448448
({ uid }) => uid === playingUid
449449
)
450450
const filteredMetadata = this.formatMetadata(trackMetadatas).filter(
@@ -453,9 +453,9 @@ class CollectionPage extends Component<
453453
item.user.name.toLowerCase().indexOf(filterText.toLowerCase()) > -1
454454
)
455455
const filteredIndex =
456-
playingIndex > -1
456+
activeIndex > -1
457457
? filteredMetadata.findIndex((metadata) => metadata.uid === playingUid)
458-
: playingIndex
458+
: activeIndex
459459
return [filteredMetadata, filteredIndex] as [
460460
typeof filteredMetadata,
461461
number

packages/web/src/pages/collection-page/components/desktop/CollectionPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const CollectionPage = ({
161161
const { status, metadata, user } = collection
162162

163163
// TODO: Consider dynamic lineups, esp. for caching improvement.
164-
const [dataSource, playingIndex] =
164+
const [dataSource, activeIndex] =
165165
tracks.status === Status.SUCCESS
166166
? getFilteredData(tracks.entries)
167167
: [[], -1]
@@ -344,7 +344,7 @@ const CollectionPage = ({
344344
loading={isNftPlaylist ? collectionLoading : tracksLoading}
345345
userId={userId}
346346
playing={playing}
347-
playingIndex={playingIndex}
347+
activeIndex={activeIndex}
348348
data={dataSource}
349349
onClickRow={onClickRow}
350350
onClickFavorite={onClickSave}

packages/web/src/pages/saved-page/SavedPageProvider.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,14 @@ class SavedPage extends PureComponent<SavedPageProps, SavedPageState> {
225225
): [SavedPageTrack[], number] => {
226226
const { tracks } = this.props
227227
const playingUid = this.getPlayingUid()
228-
const playingIndex = tracks.entries.findIndex(
228+
const activeIndex = tracks.entries.findIndex(
229229
({ uid }: any) => uid === playingUid
230230
)
231231
const filteredMetadata = this.formatMetadata(trackMetadatas)
232232
const filteredIndex =
233-
playingIndex > -1
233+
activeIndex > -1
234234
? filteredMetadata.findIndex((metadata) => metadata.uid === playingUid)
235-
: playingIndex
235+
: activeIndex
236236
return [filteredMetadata, filteredIndex]
237237
}
238238

@@ -242,7 +242,7 @@ class SavedPage extends PureComponent<SavedPageProps, SavedPageState> {
242242
const { tracks } = this.props
243243
const filterText = this.state.filterText ?? ''
244244
const playingUid = this.getPlayingUid()
245-
const playingIndex = tracks.entries.findIndex(
245+
const activeIndex = tracks.entries.findIndex(
246246
({ uid }: any) => uid === playingUid
247247
)
248248
const filteredMetadata = this.formatMetadata(trackMetadatas)
@@ -253,9 +253,9 @@ class SavedPage extends PureComponent<SavedPageProps, SavedPageState> {
253253
item.user?.name.toLowerCase().indexOf(filterText.toLowerCase()) > -1
254254
)
255255
const filteredIndex =
256-
playingIndex > -1
256+
activeIndex > -1
257257
? filteredMetadata.findIndex((metadata) => metadata.uid === playingUid)
258-
: playingIndex
258+
: activeIndex
259259
return [filteredMetadata, filteredIndex]
260260
}
261261

packages/web/src/pages/saved-page/components/desktop/SavedPage.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ const SavedPage = ({
138138
})
139139

140140
const getTracksTableData = (): [SavedPageTrack[], number] => {
141-
let [data, playingIndex] = getFilteredData(entries)
141+
let [data, activeIndex] = getFilteredData(entries)
142142
if (!hasReachedEnd) {
143143
// Add in some empty rows to show user that more are loading in
144144
data = data.concat(new Array(5).fill({ kind: Kind.EMPTY }))
145145
}
146-
return [data, playingIndex]
146+
return [data, activeIndex]
147147
}
148148

149-
const [dataSource, playingIndex] =
149+
const [dataSource, activeIndex] =
150150
status === Status.SUCCESS || entries.length
151151
? getTracksTableData()
152152
: [[], -1]
@@ -244,7 +244,7 @@ const SavedPage = ({
244244
onClickRow={onClickRow}
245245
onSort={allTracksFetched ? onSortTracks : onSortChange}
246246
playing={queuedAndPlaying}
247-
activeIndex={playingIndex}
247+
activeIndex={activeIndex}
248248
scrollRef={mainContentRef}
249249
useLocalSort={allTracksFetched}
250250
fetchBatchSize={50}

0 commit comments

Comments
 (0)