Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
[C-2123] Fix collection lineup when coming online (#2840)
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptype committed Feb 14, 2023
1 parent 65d3edf commit 1adb1ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/mobile/src/components/lineup/Lineup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export const Lineup = ({

useReachableEffect(
useCallback(() => {
if (entries.length > 0 || status === Status.LOADING) return
if (status === Status.LOADING) return
handleLoadMore(true)
// using the latest creates infinite loop, and we only need the initial state
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { formatCount } from 'app/utils/format'
import { CollectionHeader } from './CollectionHeader'
import { useCollectionLineup } from './useCollectionLineup'
const { getCollectionUid, getUserUid } = collectionPageSelectors
const { resetCollection } = collectionPageActions
const { fetchCollection, resetCollection } = collectionPageActions
const { getPlaying, getUid, getCurrentTrack } = playerSelectors
const { getIsReachable } = reachabilitySelectors

Expand Down Expand Up @@ -94,8 +94,13 @@ export const CollectionScreenDetailsTile = ({

const fetchLineup = useCallback(() => {
dispatch(resetCollection(collectionUid, userUid))

// Need to refetch the collection after resetting
// Will pull from cache if it exists
// TODO: fix this for smart collections
dispatch(fetchCollection(collectionId as number))
dispatch(tracksActions.fetchLineupMetadatas(0, 200, false, undefined))
}, [dispatch, collectionUid, userUid])
}, [dispatch, collectionUid, userUid, collectionId])

const { entries, status } = useCollectionLineup(collectionId, fetchLineup)
const trackUids = useMemo(() => entries.map(({ uid }) => uid), [entries])
Expand Down
10 changes: 5 additions & 5 deletions packages/web/src/common/store/pages/collection/lineups/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function* getCollectionTracks() {
collection = yield call(waitForValue, getCollection)
}

const track = collection.playlist_contents.track_ids
const tracks = collection.playlist_contents.track_ids

const trackIds = track.map((t) => t.track)
const trackIds = tracks.map((t) => t.track)
// TODO: Conform all timestamps to be of the same format so we don't have to do any special work here.
const times = track.map((t) => t.metadata_time ?? t.time)
const times = tracks.map((t) => t.metadata_time ?? t.time)

// Reconcile fetching this playlist with the queue.
// Search the queue for its currently playing uids. If any are sourced
Expand Down Expand Up @@ -85,8 +85,8 @@ function* getCollectionTracks() {
}
if (uidForSource[id] && uidForSource[id].length > 0) {
metadata.uid = uidForSource[id].shift()
} else if (track[i].uid) {
metadata.uid = track[i].uid
} else if (tracks[i].uid) {
metadata.uid = tracks[i].uid
}
return metadata
})
Expand Down

0 comments on commit 1adb1ad

Please sign in to comment.