From e69e66f5f78867b4118f0feb92ff671cfc83c43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 22 Feb 2024 21:58:03 -0600 Subject: [PATCH] feat: 8 day dev cooldown --- src/app/layout.tsx | 13 +++++++++---- src/stores/app.ts | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 6082bdf9e..0cca2cf74 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -13,6 +13,8 @@ import { useApp } from '../stores/app'; config(); +const DEV_BUILD_AGREEMENT_COOLDOWN = 8 * 24 * 60 * 60 * 1000; + interface RootLayoutProps { children: ReactNode; } @@ -29,7 +31,10 @@ export default function RootLayout({ children }: RootLayoutProps) { useEffect(() => { 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) { . Also consider using{' '} - the more stable version + the more stable release version - . + . You will be asked again in 8 days. @@ -78,7 +83,7 @@ export default function RootLayout({ children }: RootLayoutProps) { variant="solid" onClick={() => { setShowDevBuildAlert(false); - useApp.setState({ bypassDevBuildAlert: true }); + useApp.setState({ devBuildAgreementTime: Date.now() }); }} > Continue diff --git a/src/stores/app.ts b/src/stores/app.ts index 9f2bf263c..1c1366937 100644 --- a/src/stores/app.ts +++ b/src/stores/app.ts @@ -2,13 +2,13 @@ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; export interface App { - bypassDevBuildAlert: boolean; + devBuildAgreementTime: number; } export const useApp = create()( persist( (set) => ({ - bypassDevBuildAlert: false, + devBuildAgreementTime: 0, }), { name: 'app' }, ),