From db4c207708e0df19dfa2e0ac07536ee3871f8306 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com>
Date: Wed, 10 Jul 2024 20:31:16 -0500
Subject: [PATCH] feat: soe friendlier checks
---
src/app/components/Checks.tsx | 191 ++++++++++++++--------------------
src/stores/app/index.ts | 2 -
2 files changed, 77 insertions(+), 116 deletions(-)
diff --git a/src/app/components/Checks.tsx b/src/app/components/Checks.tsx
index b22ac8dce..314d9657d 100644
--- a/src/app/components/Checks.tsx
+++ b/src/app/components/Checks.tsx
@@ -1,19 +1,10 @@
'use client';
-import {
- AlertDialog,
- Button,
- Flex,
- Heading,
- Link,
- Text,
-} from '@radix-ui/themes';
+import { Button, Flex, Heading, Link, Text } from '@radix-ui/themes';
import { usePathname } from 'next/navigation';
import { useEffect, useState } from 'react';
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
import { idToRegion } from '../../core/blitz/idToRegion';
-import isDev from '../../core/blitzkit/isDev';
-import { isLocalhost } from '../../core/blitzkit/isLocalhost';
import * as App from '../../stores/app';
import { CURRENT_POLICIES_AGREEMENT_INDEX } from '../../stores/app/constants';
import { PatreonAuthResponse } from '../auth/[provider]/page';
@@ -26,15 +17,11 @@ interface Extension {
};
}
-const DEV_BUILD_AGREEMENT_COOLDOWN = 8 * 24 * 60 * 60 * 1000;
-
/**
* Wargaming: 14 (refresh: 7)
* Patreon: 31 (refresh: 15)
*/
-
export function Checks() {
- const [showDevBuildAlert, setShowDevBuildAlert] = useState(false);
const mutateApp = App.useMutation();
const logins = App.use((state) => state.logins);
const appStore = App.useStore();
@@ -46,17 +33,27 @@ export function Checks() {
const [showPoliciesAgreement, setShowPoliciesAgreement] = useState(false);
useEffect(() => {
- setShowDevBuildAlert(
- isDev() &&
- !isLocalhost() &&
- Date.now() - appStore.getState().devBuildAgreementTime >=
- DEV_BUILD_AGREEMENT_COOLDOWN,
- );
- }, []);
- useEffect(() => {
- setShowPoliciesAgreement(
- policiesAgreementIndex !== CURRENT_POLICIES_AGREEMENT_INDEX && !isLegal,
- );
+ function unsubscribe() {
+ window.removeEventListener('scroll', show);
+ window.removeEventListener('pointermove', show);
+ window.removeEventListener('pointerdown', show);
+ }
+
+ function show() {
+ setShowPoliciesAgreement(true);
+ unsubscribe();
+ }
+
+ if (
+ policiesAgreementIndex !== CURRENT_POLICIES_AGREEMENT_INDEX &&
+ !isLegal
+ ) {
+ window.addEventListener('scroll', show);
+ window.addEventListener('pointermove', show);
+ window.addEventListener('pointerdown', show);
+ }
+
+ return unsubscribe;
}, [policiesAgreementIndex, isLegal]);
useEffect(() => {
@@ -121,102 +118,68 @@ export function Checks() {
}
});
+ if (!showPoliciesAgreement) return null;
+
return (
- <>
-
-
- Experimental version!
-
- This version may have a lot of issues. Report issues to{' '}
-
- the official Discord server
-
- . Also consider using{' '}
- the more stable release version.
- You will be asked again in 8 days.
-
-
-
-
-
-
-
-
- {showPoliciesAgreement && (
+
+
-
-
-
-
- {policiesAgreementIndex === -1
- ? "BlitzKit's policies"
- : "BlitzKit's policies have changed"}
-
+
+
+ {policiesAgreementIndex === -1
+ ? "BlitzKit's policies"
+ : "BlitzKit's policies have changed"}
+
-
- This website utilizes cookies to perform analytics and
- personalize your experience. You can learn more through{' '}
-
- our privacy policy
-
- . You may opt out of personalized advertizement by visiting{' '}
-
- Google Ad Settings
-
- . By using BlitzKit, you also agree to our{' '}
-
- terms of service
-
- .
-
-
-
-
-
+
+ This website utilizes cookies to perform analytics and personalize
+ your experience. You can learn more through{' '}
+ our privacy policy.
+ You may opt out of personalized advertizement by visiting{' '}
+ WebChoices. By
+ using BlitzKit, you also agree to our{' '}
+ terms of service.
+
+
+
- )}
- >
+
+
);
}
diff --git a/src/stores/app/index.ts b/src/stores/app/index.ts
index 85be06411..93ed17082 100644
--- a/src/stores/app/index.ts
+++ b/src/stores/app/index.ts
@@ -18,7 +18,6 @@ interface PatreonLogin {
}
export interface App {
- devBuildAgreementTime: number;
developerMode: boolean;
logins: {
wargaming?: WargamingLogin;
@@ -32,7 +31,6 @@ export const { Provider, use, useMutation, useStore } = createNextSafeStore(
create()(
persist(
(set) => ({
- devBuildAgreementTime: 0,
developerMode: false,
policiesAgreementIndex: -1,
logins: {},