From 7a4b0412c274c4dc815fd9897ad81bf3d4c88fd9 Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Thu, 23 Dec 2021 23:39:16 +0700 Subject: [PATCH] Update excel export if banner time mismatch --- src/functions/wish.js | 16 +++++++++++----- src/routes/wish/[id].svelte | 10 +++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/functions/wish.js b/src/functions/wish.js index b32a7834..f58985f6 100644 --- a/src/functions/wish.js +++ b/src/functions/wish.js @@ -100,6 +100,8 @@ export async function process(id) { let startBanner = false; let currentBannerIndex = -1; let hasManualInput = false; + let lastBanner; + let lastBannerIndex; let pity = 0; for (let i = 0; i < pullData.length; i++) { @@ -108,18 +110,22 @@ export async function process(id) { const currentPullTime = dayjs(pull.time).unix(); if (currentBanner === null || currentBanner.end < currentPullTime) { + lastBannerIndex = currentBannerIndex; + const nextBanner = getNextBanner(currentPullTime, currentBannerIndex, selectedBanners); if (nextBanner === undefined) { console.log('error banner here', JSON.stringify(pull)); pushToast(t('wish.errorBanner'), 'error'); - return null; + currentBannerIndex = lastBannerIndex; + currentBanner = lastBanner; + } else { + currentBanner = nextBanner.selectedBanner; + currentBannerIndex = nextBanner.currentBannerIndex; + lastBanner = currentBanner; + startBanner = true; } - currentBanner = nextBanner.selectedBanner; - currentBannerIndex = nextBanner.currentBannerIndex; - startBanner = true; - if (i > 0) { currentPulls[i - 1].end = true; } diff --git a/src/routes/wish/[id].svelte b/src/routes/wish/[id].svelte index f8616e56..4848ba81 100644 --- a/src/routes/wish/[id].svelte +++ b/src/routes/wish/[id].svelte @@ -156,6 +156,7 @@ let startBanner = false; let rateUp = false; let lastBanner; + let lastBannerIndex; for (let i = 0; i < pullData.length; i++) { const pull = pullData[i]; @@ -163,19 +164,22 @@ const currentPullTime = dayjs(pull.time).unix(); if (currentBanner === null || currentBanner.end < currentPullTime) { + lastBannerIndex = currentBannerIndex; + currentBanner = getNextBanner(currentPullTime); if (currentBanner === undefined) { - // console.log('error banner here', JSON.stringify(pull)); + console.log('error banner here', JSON.stringify(pull)); // errorProcessingPull = pull; // pushToast($t('wish.errorBanner'), 'error'); // return; - + currentBannerIndex = lastBannerIndex; currentBanner = lastBanner; + } else { + startBanner = true; } lastBanner = currentBanner; - startBanner = true; if (i > 0) { currentPulls[i - 1].end = true;