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 [] 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[] = []

View file

@ -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,