From 463371de180e812cc2fc2c2fb5b2253cf65a29dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Sun, 16 Jun 2024 17:08:44 -0500 Subject: [PATCH] feat: cache exempt --- src/hooks/useAdExempt.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/useAdExempt.ts b/src/hooks/useAdExempt.ts index 1aae3da9a..d7db86bcf 100644 --- a/src/hooks/useAdExempt.ts +++ b/src/hooks/useAdExempt.ts @@ -1,7 +1,11 @@ import { use } from 'react'; import { useApp } from '../stores/app'; +let cache: boolean | undefined = undefined; + export function useAdExempt() { + if (cache !== undefined) return cache; + const patreon = useApp((state) => state.logins.patreon); if (!patreon) return false; @@ -12,5 +16,8 @@ export function useAdExempt() { }).then((response) => response.json()), ); - return typeof json === 'boolean' && json; + const exempt = typeof json === 'boolean' && json; + cache = exempt; + + return exempt; }