Don't push streams if there are no new ones

This commit is contained in:
dragongoose 2023-07-29 21:09:25 -04:00
parent 957dc4da9a
commit 4222967da7
No known key found for this signature in database
GPG Key ID: 01397EEC371CDAA5

View File

@ -44,17 +44,24 @@ export default {
if (!cursor) return if (!cursor) return
// get rest of streams from api // get rest of streams from api
const resData = await getEndpoint( const resData: CategoryData = await getEndpoint(
`api/discover/${this.$route.params.game}/?cursor=${cursor}` `api/discover/${this.$route.params.game}/?cursor=${cursor}`
).catch((err) => { ).catch((err) => {
throw err throw err
}) })
let lastStreamCursor = this.data!.streams[this.data!.streams.length-1].cursor
let newLastStreamCursor = resData.streams[resData.streams.length-1].cursor
if (lastStreamCursor === newLastStreamCursor) {
// Add "no more streams!" screen later
console.log("no more streams!")
} else {
for (let stream of resData.streams) { for (let stream of resData.streams) {
this.data!.streams.push(stream) this.data!.streams.push(stream)
} }
} }
} }
}
}, },
abbreviate abbreviate
}, },