From 6a45b8b6bc344b8a9832969f825f02fd72e214e1 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Tue, 2 Aug 2022 11:34:52 +0200 Subject: [PATCH] Revert "Update api fetching" This reverts commit b921801e6a8df0a556202437d40ad676e11e6b64. --- docker/schwarzesbrett/src/routes/index.svelte | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/docker/schwarzesbrett/src/routes/index.svelte b/docker/schwarzesbrett/src/routes/index.svelte index de8cdb8..e916a15 100644 --- a/docker/schwarzesbrett/src/routes/index.svelte +++ b/docker/schwarzesbrett/src/routes/index.svelte @@ -5,6 +5,10 @@ let listingIndex = 0; function updateListingIndex(amount: number): void { + if (listingIndex == amount - 2) { + fetchData = api.fetchData(); + } + if (listingIndex >= amount - 1) { listingIndex = 0; } else { @@ -12,25 +16,16 @@ } } - function handleTime( - time: number, - index: number, - listingsAmount: number - ): void { - if (index == listingsAmount - 2) { - fetchData = api.fetchData(); - } - + function handleTime(time: number, listingsAmount: number): void { setTimeout(() => updateListingIndex(listingsAmount), time * 1000); } function handleVideoLoad( time: number | undefined, - index: number, listingsAmount: number ): void { if (time) { - handleTime(time, index, listingsAmount); + handleTime(time, listingsAmount); } } @@ -49,7 +44,6 @@ on:load={() => handleTime( data.listings[listingIndex].time || 10, - listingIndex, data.listings.length )} /> @@ -61,7 +55,6 @@ on:load={() => handleVideoLoad( data.listings[listingIndex].time, - listingIndex, data.listings.length )} on:ended={() => updateListingIndex(data.listings.length)}