0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2024-12-22 13:22:58 -05:00
This commit is contained in:
dragongoose 2024-01-01 14:17:27 -05:00
parent fd45be88d5
commit 7d2c722fac
No known key found for this signature in database
GPG key ID: 01397EEC371CDAA5
2 changed files with 19 additions and 8 deletions

View file

@ -107,7 +107,7 @@ export async function followersStreaming(streamers: string[]): Promise<string[]>
return []
}
const data: StreamerData[] = await postEndpoint('api/users/bulk', payload)
const data: StreamerData[] = await postEndpoint('api/users/followingStreamer/bulk', payload)
const liveStreamers: string[] = []

View file

@ -12,7 +12,7 @@ import type { StreamerData } from '@/types'
export default {
inject: ['rootBackendUrl'],
setup() {
let data = ref<StreamerData[]>()
let data = ref<StreamerData[]>([])
let status = ref<'ok' | 'error'>()
return {
@ -27,23 +27,34 @@ export default {
async mounted() {
const follows = getFollows()
const payload = {
streamers: follows
}
// do not make request if no followers
if (follows.length == 0) {
this.data = []
return
}
await postEndpoint('api/users/bulk', payload)
// split follows into 35 person segments
// the endpoint can only handle 35 at a time
let payloads: string[][] = []
for (let i = 0; i < follows.length; i += 35) {
const chunk = follows.slice(i, i + 35)
payloads.push(chunk)
}
for (let i = 0; i < payloads.length; i++) {
const payload = {
streamers: payloads[i]
}
await postEndpoint('api/users/followingStreamer/bulk', payload)
.catch(() => {
this.status = 'error'
})
.then((data: StreamerData[]) => {
this.data = data
this.data = [...this.data, ...data]
})
}
},
components: {
LoadingScreen,