feat: 8 day dev cooldown

This commit is contained in:
TrèsAbhi committed 2024-02-22 21:58:03 -06:00
1 parent b9c5c3c931
commit e69e66f5f7
2 files changed
+11 -6

No files matched your search

+9 -4
View File
@@ -13,6 +13,8 @@ import { useApp } from '../stores/app';
config(); config();
const DEV_BUILD_AGREEMENT_COOLDOWN = 8 * 24 * 60 * 60 * 1000;
interface RootLayoutProps { interface RootLayoutProps {
children: ReactNode; children: ReactNode;
} }
@@ -29,7 +31,10 @@ export default function RootLayout({ children }: RootLayoutProps) {
useEffect(() => { useEffect(() => {
setShowDevBuildAlert( setShowDevBuildAlert(
isDev() && !isLocalhost() && !useApp.getState().bypassDevBuildAlert, isDev() &&
!isLocalhost() &&
Date.now() - useApp.getState().devBuildAgreementTime >=
DEV_BUILD_AGREEMENT_COOLDOWN,
); );
}, []); }, []);
@@ -68,9 +73,9 @@ export default function RootLayout({ children }: RootLayoutProps) {
</a> </a>
. Also consider using{' '} . Also consider using{' '}
<a href="https://blitz-krieg.vercel.app/"> <a href="https://blitz-krieg.vercel.app/">
the more stable version the more stable release version
</a> </a>
. . You will be asked again in 8 days.
</AlertDialog.Description> </AlertDialog.Description>
<Flex justify="end"> <Flex justify="end">
@@ -78,7 +83,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
variant="solid" variant="solid"
onClick={() => { onClick={() => {
setShowDevBuildAlert(false); setShowDevBuildAlert(false);
useApp.setState({ bypassDevBuildAlert: true }); useApp.setState({ devBuildAgreementTime: Date.now() });
}} }}
> >
Continue Continue
+2 -2
View File
@@ -2,13 +2,13 @@ import { create } from 'zustand';
import { persist } from 'zustand/middleware'; import { persist } from 'zustand/middleware';
export interface App { export interface App {
bypassDevBuildAlert: boolean; devBuildAgreementTime: number;
} }
export const useApp = create<App>()( export const useApp = create<App>()(
persist( persist(
(set) => ({ (set) => ({
bypassDevBuildAlert: false, devBuildAgreementTime: 0,
}), }),
{ name: 'app' }, { name: 'app' },
), ),