This commit is contained in:
kakkokari-gtyih 2024-10-20 18:37:15 +09:00
parent b2d57badf9
commit 455f911aae
1 changed files with 5 additions and 2 deletions

View File

@ -248,8 +248,11 @@ export async function mainBoot() {
} }
window.addEventListener('visibilitychange', () => { window.addEventListener('visibilitychange', () => {
const now = Date.now();
if (document.visibilityState === 'visible') { if (document.visibilityState === 'visible') {
if ((Date.now() - lastVisibilityChangedAt) < 1000 * 10) { // タブを高速で切り替えたら取得処理が何度も走るのを防ぐ
if ((now - lastVisibilityChangedAt) < 1000 * 10) {
justPlainLuckyTimer = window.setTimeout(claimPlainLucky, 1000 * 10); justPlainLuckyTimer = window.setTimeout(claimPlainLucky, 1000 * 10);
} else { } else {
claimPlainLucky(); claimPlainLucky();
@ -259,7 +262,7 @@ export async function mainBoot() {
justPlainLuckyTimer = null; justPlainLuckyTimer = null;
} }
lastVisibilityChangedAt = Date.now(); lastVisibilityChangedAt = now;
}, { passive: true }); }, { passive: true });
claimPlainLucky(); claimPlainLucky();