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

Commit

Permalink
fix more by artist lineup (#1921)
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 committed Sep 14, 2022
1 parent 7a95b3f commit 5a496fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/common/src/store/pages/track/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const actionsMap = {
[RESET](state, action) {
return {
...state,
...initialState
...initialState,
tracks: tracksLineupReducer(undefined, action)
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions packages/mobile/src/screens/track-screen/TrackScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useRoute } from 'app/hooks/useRoute'
import { makeStyles } from 'app/styles'

import { TrackScreenMainContent } from './TrackScreenMainContent'
const { fetchTrack } = trackPageActions
const { fetchTrack, resetTrackPage } = trackPageActions
const { tracksActions } = trackPageLineupActions
const { getLineup, getRemixParentTrack, getTrack, getUser } = trackPageSelectors
const { makeGetLineupMetadatas } = lineupSelectors
Expand Down Expand Up @@ -58,10 +58,6 @@ export const TrackScreen = () => {
// params is incorrectly typed and can sometimes be undefined
const { searchTrack, id } = params ?? {}

useEffect(() => {
dispatch(fetchTrack(id, undefined, undefined, true))
}, [dispatch, id])

const cachedTrack = useSelector((state) => getTrack(state, params))

const track = cachedTrack ?? searchTrack
Expand All @@ -74,6 +70,14 @@ export const TrackScreen = () => {

const lineup = useSelector(getMoreByArtistLineup)
const remixParentTrack = useSelector(getRemixParentTrack)
const trackUserExists = user != null
useEffect(() => {
dispatch(fetchTrack(id, undefined, user?.handle, true))
return () => {
dispatch(resetTrackPage())
dispatch(tracksActions.reset())
}
}, [dispatch, id, trackUserExists, user?.handle])

if (!track || !user) {
console.warn(
Expand Down
7 changes: 5 additions & 2 deletions packages/web/src/common/store/pages/track/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function* getRestOfLineup(permalink, ownerHandle) {
function* watchFetchTrack() {
yield takeEvery(trackPageActions.FETCH_TRACK, function* (action) {
const { trackId, handle, slug, canBeUnlisted } = action
const permalink = `/${handle}/${slug}`
try {
let track
if (!trackId) {
Expand Down Expand Up @@ -171,7 +170,11 @@ function* watchFetchTrack() {
// Add hero track to lineup early so that we can play it ASAP
// (instead of waiting for the entire lineup to load)
yield call(addTrackToLineup, track)
yield fork(getRestOfLineup, permalink, handle)
yield fork(
getRestOfLineup,
track.permalink,
handle || track.permalink.split('/')?.[1]
)
yield fork(getTrackRanks, track.track_id)
yield put(trackPageActions.fetchTrackSucceeded(track.track_id))
}
Expand Down

0 comments on commit 5a496fa

Please sign in to comment.