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;