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 []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const data: StreamerData[] = await postEndpoint('api/users/bulk', payload)
|
const data: StreamerData[] = await postEndpoint('api/users/followingStreamer/bulk', payload)
|
||||||
|
|
||||||
const liveStreamers: string[] = []
|
const liveStreamers: string[] = []
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import type { StreamerData } from '@/types'
|
||||||
export default {
|
export default {
|
||||||
inject: ['rootBackendUrl'],
|
inject: ['rootBackendUrl'],
|
||||||
setup() {
|
setup() {
|
||||||
let data = ref<StreamerData[]>()
|
let data = ref<StreamerData[]>([])
|
||||||
let status = ref<'ok' | 'error'>()
|
let status = ref<'ok' | 'error'>()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -27,23 +27,34 @@ export default {
|
||||||
async mounted() {
|
async mounted() {
|
||||||
const follows = getFollows()
|
const follows = getFollows()
|
||||||
|
|
||||||
const payload = {
|
|
||||||
streamers: follows
|
|
||||||
}
|
|
||||||
|
|
||||||
// do not make request if no followers
|
// do not make request if no followers
|
||||||
if (follows.length == 0) {
|
if (follows.length == 0) {
|
||||||
this.data = []
|
this.data = []
|
||||||
return
|
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(() => {
|
.catch(() => {
|
||||||
this.status = 'error'
|
this.status = 'error'
|
||||||
})
|
})
|
||||||
.then((data: StreamerData[]) => {
|
.then((data: StreamerData[]) => {
|
||||||
this.data = data
|
this.data = [...this.data, ...data]
|
||||||
})
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
LoadingScreen,
|
LoadingScreen,
|
||||||
|
|
Loading…
Reference in a new issue