feat: soe friendlier checks

This commit is contained in:
TrèsAbhi committed 2024-07-10 20:31:16 -05:00
1 parent d86af7e7ab
commit db4c207708
2 files changed
+34 -73

No files matched your search

+34 -71
View File
@@ -1,19 +1,10 @@
'use client'; 'use client';
import { import { Button, Flex, Heading, Link, Text } from '@radix-ui/themes';
AlertDialog,
Button,
Flex,
Heading,
Link,
Text,
} from '@radix-ui/themes';
import { usePathname } from 'next/navigation'; import { usePathname } from 'next/navigation';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID'; import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
import { idToRegion } from '../../core/blitz/idToRegion'; 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 * as App from '../../stores/app';
import { CURRENT_POLICIES_AGREEMENT_INDEX } from '../../stores/app/constants'; import { CURRENT_POLICIES_AGREEMENT_INDEX } from '../../stores/app/constants';
import { PatreonAuthResponse } from '../auth/[provider]/page'; 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) * Wargaming: 14 (refresh: 7)
* Patreon: 31 (refresh: 15) * Patreon: 31 (refresh: 15)
*/ */
export function Checks() { export function Checks() {
const [showDevBuildAlert, setShowDevBuildAlert] = useState(false);
const mutateApp = App.useMutation(); const mutateApp = App.useMutation();
const logins = App.use((state) => state.logins); const logins = App.use((state) => state.logins);
const appStore = App.useStore(); const appStore = App.useStore();
@@ -46,17 +33,27 @@ export function Checks() {
const [showPoliciesAgreement, setShowPoliciesAgreement] = useState(false); const [showPoliciesAgreement, setShowPoliciesAgreement] = useState(false);
useEffect(() => { useEffect(() => {
setShowDevBuildAlert( function unsubscribe() {
isDev() && window.removeEventListener('scroll', show);
!isLocalhost() && window.removeEventListener('pointermove', show);
Date.now() - appStore.getState().devBuildAgreementTime >= window.removeEventListener('pointerdown', show);
DEV_BUILD_AGREEMENT_COOLDOWN, }
);
}, []); function show() {
useEffect(() => { setShowPoliciesAgreement(true);
setShowPoliciesAgreement( unsubscribe();
policiesAgreementIndex !== CURRENT_POLICIES_AGREEMENT_INDEX && !isLegal, }
);
if (
policiesAgreementIndex !== CURRENT_POLICIES_AGREEMENT_INDEX &&
!isLegal
) {
window.addEventListener('scroll', show);
window.addEventListener('pointermove', show);
window.addEventListener('pointerdown', show);
}
return unsubscribe;
}, [policiesAgreementIndex, isLegal]); }, [policiesAgreementIndex, isLegal]);
useEffect(() => { useEffect(() => {
@@ -121,36 +118,9 @@ export function Checks() {
} }
}); });
if (!showPoliciesAgreement) return null;
return ( return (
<>
<AlertDialog.Root open={showDevBuildAlert}>
<AlertDialog.Content>
<AlertDialog.Title>Experimental version!</AlertDialog.Title>
<AlertDialog.Description>
This version may have a lot of issues. Report issues to{' '}
<a href="https://discord.gg/nDt7AjGJQH" target="_blank">
the official Discord server
</a>
. Also consider using{' '}
<a href="https://blitzkit.app/">the more stable release version</a>.
You will be asked again in 8 days.
</AlertDialog.Description>
<Flex justify="end">
<Button
variant="solid"
onClick={() => {
setShowDevBuildAlert(false);
appStore.setState({ devBuildAgreementTime: Date.now() });
}}
>
Continue
</Button>
</Flex>
</AlertDialog.Content>
</AlertDialog.Root>
{showPoliciesAgreement && (
<Flex <Flex
align="end" align="end"
style={{ style={{
@@ -187,36 +157,29 @@ export function Checks() {
</Heading> </Heading>
<Text> <Text>
This website utilizes cookies to perform analytics and This website utilizes cookies to perform analytics and personalize
personalize your experience. You can learn more through{' '} your experience. You can learn more through{' '}
<Link href="/docs/legal/privacy-policy"> <Link href="/docs/legal/privacy-policy">our privacy policy</Link>.
our privacy policy You may opt out of personalized advertizement by visiting{' '}
</Link> <Link href="https://optout.aboutads.info/">WebChoices</Link>. By
. You may opt out of personalized advertizement by visiting{' '} using BlitzKit, you also agree to our{' '}
<Link href="https://www.google.com/settings/ads"> <Link href="/docs/legal/terms-of-service">terms of service</Link>.
Google Ad Settings
</Link>
. By using BlitzKit, you also agree to our{' '}
<Link href="/docs/legal/terms-of-service">
terms of service
</Link>
.
</Text> </Text>
</Flex> </Flex>
<Button <Button
mt="2"
onClick={() => { onClick={() => {
appStore.setState({ appStore.setState({
policiesAgreementIndex: CURRENT_POLICIES_AGREEMENT_INDEX, policiesAgreementIndex: CURRENT_POLICIES_AGREEMENT_INDEX,
}); });
setShowPoliciesAgreement(false);
}} }}
> >
I Agree I agree
</Button> </Button>
</Flex> </Flex>
</Flex> </Flex>
</Flex> </Flex>
)}
</>
); );
} }
-2
View File
@@ -18,7 +18,6 @@ interface PatreonLogin {
} }
export interface App { export interface App {
devBuildAgreementTime: number;
developerMode: boolean; developerMode: boolean;
logins: { logins: {
wargaming?: WargamingLogin; wargaming?: WargamingLogin;
@@ -32,7 +31,6 @@ export const { Provider, use, useMutation, useStore } = createNextSafeStore(
create<App>()( create<App>()(
persist( persist(
(set) => ({ (set) => ({
devBuildAgreementTime: 0,
developerMode: false, developerMode: false,
policiesAgreementIndex: -1, policiesAgreementIndex: -1,
logins: {}, logins: {},