From 526fddc7a50debad01f202ac772325391d07cc35 Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Sun, 12 Dec 2021 22:24:40 +0700 Subject: [PATCH] Update wish import tutorial video --- src/functions/wish.js | 5 ++++ src/functions/wishTally.js | 29 ++++++++++++++++++++- src/locales/en.json | 9 ++++++- src/routes/wish/import.svelte | 49 +++++++++++++++++++++++++++++------ 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/src/functions/wish.js b/src/functions/wish.js index 5ef87cc6..b32a7834 100644 --- a/src/functions/wish.js +++ b/src/functions/wish.js @@ -203,5 +203,10 @@ export async function process(id) { pulls: currentPulls, banner: selectedBanners, hasManualInput, + tally: { + allTotal: data.total, + legendaryTotal: allLegendary.length, + rareTotal: allRare.length, + }, }; } diff --git a/src/functions/wishTally.js b/src/functions/wishTally.js index 79f4fe25..71d6557d 100644 --- a/src/functions/wishTally.js +++ b/src/functions/wishTally.js @@ -1,4 +1,6 @@ import dayjs from 'dayjs'; +import { getAccountPrefix } from '../stores/account'; +import { readSave } from '../stores/saveManager'; import { process } from './wish'; const bannerCategories = ['beginners', 'standard', 'character-event', 'weapon-event']; @@ -15,8 +17,24 @@ async function sendWish(data) { } } +async function sendWishTotal(data) { + try { + await fetch(`${__paimon.env.API_HOST}/wish/total`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }); + } catch (err) { + console.error(err); + } +} + export async function submitWishTally() { let prefixId = 0; + + const prefixAccount = getAccountPrefix(); + const uid = await readSave(`${prefixAccount}wish-uid`); + for (const id of bannerCategories) { prefixId += 100000; @@ -26,7 +44,15 @@ export async function submitWishTally() { console.log('processing wish tally', id); - const { pulls, banner } = data; + const { pulls, banner, tally } = data; + + await sendWishTotal({ + type: id, + uid, + total: tally.allTotal, + legendary: tally.legendaryTotal, + rare: tally.rareTotal, + }); const firstFivePulls = pulls .slice(0, 5) @@ -90,6 +116,7 @@ export async function submitWishTally() { legendary: legendaryCount, rare: rareCount, pityCount, + uid, }); } } diff --git a/src/locales/en.json b/src/locales/en.json index 21d1457b..f4ff9325 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -180,6 +180,11 @@ "and", "pity from your wish history" ], + "header": [ + "Import and backup your Genshin Impact wish history to keep it more than 6 months. Also automatically track your pity and statistic about your wishes!", + "You can also enable Drive Sync on Setting to synchronize and backup the history to your Google Drive", + "Please note that the old feedback link does not work anymore, please follow the new instruction below!" + ], "faqs": { "title": "Import Wish History FAQ", "q1": "How does it work?", @@ -281,7 +286,9 @@ "Back to Stream App > Stop Sniffing", "Click Sniff History > Choose a request that end by .json (the link start with https://hk4e-api-os.mihoyo.com/)", "Click Request tab, then copy the link and paste it below", - "Paste link here... https://hk4e-api-os.mihoyo.com..." + "Paste link here... https://hk4e-api-os.mihoyo.com...", + "If you got any problem, see troubleshooting guide", + "https://docs.google.com/document/d/1U8pf9lqKALtMSWI11t_6npYlVOCpIFZZRvhrC_9-2ek/edit" ], "ps": [ "The steps below might be not working, you can link your PS account with miHoYo account then use the pc/mobile instruction", diff --git a/src/routes/wish/import.svelte b/src/routes/wish/import.svelte index 0fed1dcf..17e6d682 100644 --- a/src/routes/wish/import.svelte +++ b/src/routes/wish/import.svelte @@ -46,6 +46,8 @@ const videoTutorial = { android: 'https://youtu.be/pe_aROJ8Av8', + pc: 'https://www.youtube.com/watch?v=FCwZkHeIezw', + pclog: 'https://www.youtube.com/watch?v=cl5HDd0bqKw', }; let types = { @@ -312,14 +314,18 @@ } calculatingPity = false; - submitWishTally(); - await updateSave(`${prefix}collectables-updated`, true); if (currentUID !== '') { await updateSave(`${prefix}wish-uid`, currentUID); } + try { + submitWishTally(); + } catch (err) { + console.error(err); + } + await updateSave(`${prefix}wish-counter-setting`, { firstTime: false, manualInput: false, @@ -624,6 +630,17 @@

{$t('wish.import.title')}

+
+ +
+

{$t('wish.import.header.0')}

+

{$t('wish.import.header.1')}

+
+ Paimon +

{$t('wish.import.header.2')}

+
+
+
@@ -770,8 +787,7 @@

{$t('wish.import.guide.pc2.3')}

-
+        
           {$server === 'China' ? $t('wish.import.guide.pc2.5') : $t('wish.import.guide.pc2.4')}
         

@@ -828,8 +844,7 @@

{$t('wish.import.guide.pclog.2')}

-
+        
           {$server === 'China' ? $t('wish.import.logLocation.china') : $t('wish.import.logLocation.global')}
         
@@ -908,7 +923,9 @@

{$t('wish.import.guide.pclocal.2')}

{$t('wish.import.guide.pclocal.3')}
+ class="bg-black text-white bg-opacity-50 whitespace-pre-wrap break-all p-2 rounded-xl text-xs select-all">{$t( + 'wish.import.guide.pclocal.3', + )}

{$t('wish.import.guide.pclocal.4')} @@ -964,11 +981,27 @@

-
+

{$t(`wish.import.guide.ios2.${i + 3}`)}

{/each} +