0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2024-12-22 13:22:58 -05:00

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,14 +44,21 @@ export default {
if (!cursor) return
// get rest of streams from api
const resData = await getEndpoint(
const resData: CategoryData = await getEndpoint(
`api/discover/${this.$route.params.game}/?cursor=${cursor}`
).catch((err) => {
throw err
})
for (let stream of resData.streams) {
this.data!.streams.push(stream)
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) {
this.data!.streams.push(stream)
}
}
}
}