feat: cache exempt

This commit is contained in:
TrèsAbhi committed 2024-06-16 17:08:44 -05:00
1 parent e6d2817524
commit 463371de18
1 file changed
+8 -1
+8 -1
View File
@@ -1,7 +1,11 @@
import { use } from 'react'; import { use } from 'react';
import { useApp } from '../stores/app'; import { useApp } from '../stores/app';
let cache: boolean | undefined = undefined;
export function useAdExempt() { export function useAdExempt() {
if (cache !== undefined) return cache;
const patreon = useApp((state) => state.logins.patreon); const patreon = useApp((state) => state.logins.patreon);
if (!patreon) return false; if (!patreon) return false;
@@ -12,5 +16,8 @@ export function useAdExempt() {
}).then((response) => response.json()), }).then((response) => response.json()),
); );
return typeof json === 'boolean' && json; const exempt = typeof json === 'boolean' && json;
cache = exempt;
return exempt;
} }