mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2024-12-22 13:22:58 -05:00
Fix 77
This commit is contained in:
parent
fd45be88d5
commit
7d2c722fac
2 changed files with 19 additions and 8 deletions
|
@ -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[] = []
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue