From 7d2c722face9649d3d325b995e5ae9c1a3f08b81 Mon Sep 17 00:00:00 2001 From: dragongoose Date: Mon, 1 Jan 2024 14:17:27 -0500 Subject: [PATCH] Fix 77 --- src/mixins.ts | 2 +- src/views/FollowingView.vue | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/mixins.ts b/src/mixins.ts index 891571a..b759ddf 100644 --- a/src/mixins.ts +++ b/src/mixins.ts @@ -107,7 +107,7 @@ export async function followersStreaming(streamers: string[]): Promise return [] } - const data: StreamerData[] = await postEndpoint('api/users/bulk', payload) + const data: StreamerData[] = await postEndpoint('api/users/followingStreamer/bulk', payload) const liveStreamers: string[] = [] diff --git a/src/views/FollowingView.vue b/src/views/FollowingView.vue index 0dfd4b8..687a167 100644 --- a/src/views/FollowingView.vue +++ b/src/views/FollowingView.vue @@ -12,7 +12,7 @@ import type { StreamerData } from '@/types' export default { inject: ['rootBackendUrl'], setup() { - let data = ref() + let data = ref([]) 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,