From 3ae3ae995c59ff2cb1b0737f7a5702c0ec37945e Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Fri, 1 Jul 2022 19:03:33 +0700 Subject: [PATCH] Check banner if exists --- src/routes/wish/import.svelte | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/routes/wish/import.svelte b/src/routes/wish/import.svelte index 4ffa5d99..e05616b3 100644 --- a/src/routes/wish/import.svelte +++ b/src/routes/wish/import.svelte @@ -411,7 +411,7 @@ const path = `wish-counter-${type.id}`; const localData = await readSave(`${prefix}${path}`); - const withRate = type.id === 'character-event' || type.id === 'weapon-event'; + let withRate = type.id === 'character-event' || type.id === 'weapon-event'; let localWishes = []; if (localData !== null) { @@ -465,20 +465,25 @@ rarity = weaponList[combined[i].id].rarity; } - const unixTime = dayjs(combined[i].time).unix(); - if (withRate && (currentSelectedBanner === null || currentSelectedBanner.end < unixTime)) { - lastBannerIndex = currentBannerIndex; + try { + const unixTime = dayjs(combined[i].time).unix(); + if (withRate && (currentSelectedBanner === null || currentSelectedBanner.end < unixTime)) { + lastBannerIndex = currentBannerIndex; - const nextBanner = getNextBanner(unixTime); + const nextBanner = getNextBanner(unixTime); - if (nextBanner === undefined) { - currentBannerIndex = lastBannerIndex; - currentSelectedBanner = lastBanner; - } else { - currentSelectedBanner = nextBanner.selectedBanner; - currentBannerIndex = nextBanner.currentBannerIndex; - lastBanner = currentSelectedBanner; + if (nextBanner === undefined) { + currentBannerIndex = lastBannerIndex; + currentSelectedBanner = lastBanner; + } else { + currentSelectedBanner = nextBanner.selectedBanner; + currentBannerIndex = nextBanner.currentBannerIndex; + lastBanner = currentSelectedBanner; + } } + } catch (err) { + withRate = false; + console.log('ERROR PARSE BANNER', combined[i]); } // guaranteed + winrateoff