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

Consume Remixes + Stems API Endpoints #33

Merged
merged 4 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/containers/remixes-page/store/lineups/tracks/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { call, put } from 'redux-saga/effects'

import AudiusBackend from 'services/AudiusBackend'

import {
PREFIX,
tracksActions
Expand All @@ -11,6 +9,9 @@ import { LineupSagas } from 'store/lineup/sagas'
import { processAndCacheTracks } from 'store/cache/tracks/utils'
import { setCount } from '../../slice'
import { AppState } from 'store/types'
import apiClient from 'services/audius-api-client/AudiusAPIClient'
import { getUserId } from 'store/account/selectors'
import { select } from 'redux-saga-test-plan/matchers'

function* getTracks({
offset,
Expand All @@ -24,10 +25,12 @@ function* getTracks({
const { trackId } = payload
if (!trackId) return []

const { tracks, count } = yield call(AudiusBackend.getRemixesOfTrack, {
const currentUserId = yield select(getUserId)
const { tracks, count } = yield call(args => apiClient.getRemixes(args), {
trackId,
offset,
limit
limit,
currentUserId
})

yield put(setCount({ count }))
Expand Down
1 change: 1 addition & 0 deletions src/models/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export type LineupTrack = UserTrack & {
}

// Track with known non-optional stem
export type StemTrackMetadata = TrackMetadata & Required<Pick<Track, 'stem_of'>>
export type StemTrack = Track & Required<Pick<Track, 'stem_of'>>
export type StemUserTrack = UserTrack & Required<Pick<Track, 'stem_of'>>

Expand Down
52 changes: 0 additions & 52 deletions src/services/AudiusBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,58 +685,6 @@ class AudiusBackend {
}
}

static async getStems({ trackId }) {
piazzatron marked this conversation as resolved.
Show resolved Hide resolved
try {
const stems = await withEagerOption(
{
normal: libs => libs.Track.getStemsForTrack,
eager: DiscoveryAPI.getStemsForTrack
},
trackId
)
return stems
} catch (e) {
console.error(e)
throw e
}
}

static async getRemixesOfTrack({ trackId, offset, limit }) {
try {
const remixes = await withEagerOption(
{
normal: libs => libs.Track.getRemixesOfTrack,
eager: DiscoveryAPI.getRemixesOfTrack
},
trackId,
limit,
offset
)
return remixes
} catch (e) {
console.error(e)
throw e
}
}

static async getRemixTrackParents({ trackId, offset, limit }) {
try {
const remixes = await withEagerOption(
{
normal: libs => libs.Track.getRemixTrackParents,
eager: DiscoveryAPI.getRemixTrackParents
},
trackId,
limit,
offset
)
return remixes
} catch (e) {
console.error(e)
throw e
}
}

static async getSocialFeed({
filter,
offset,
Expand Down
Loading