Skip to content

Commit

Permalink
more data is loading from initial render only
Browse files Browse the repository at this point in the history
  • Loading branch information
sobhanbera committed Jul 24, 2021
1 parent 2e5942f commit aa3d794
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions app/screens/main/Explore/SongCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const SongCategoryScreen = (props: Props) => {
songs.continuation.clickTrackingParams &&
songs.continuation.continuation
) {
console.log('LOADING MORE SONGS')
setLoading(true)
getContinuation('search', songs.continuation, 'SONG')
.then((res: FetchedSongObject) => {
Expand All @@ -72,7 +71,6 @@ const SongCategoryScreen = (props: Props) => {
})
.catch(_err => {
setLoading(false)
console.log('ERR CONTINUE FETCH SONGS')
})
}
}
Expand All @@ -83,18 +81,27 @@ const SongCategoryScreen = (props: Props) => {
search(category.name, 'SONG')
.then((res: FetchedSongObject) => {
setSongs(res)
setLoading(true)
getContinuation('search', songs.continuation, 'SONG')
.then((res: FetchedSongObject) => {
const data = songs.content.concat(res.content)
setSongs({
content: data,
continuation: res.continuation,
})
setLoading(false)
})
.catch(_err => {
setLoading(false)
})
})
.catch(_err => {
console.log('ERR FETCH SONGS')
})
.catch(_err => {})

search(category.name, 'ARTIST')
.then((res: FetchedArtistObject) => {
setArtists(res)
})
.catch(_err => {
console.log('ERR FETCH ARTISTS')
})
.catch(_err => {})

return () => {
setSongs(BareFetchedSongObjectInstance)
Expand Down

0 comments on commit aa3d794

Please sign in to comment.