feat: patreon exempt

This commit is contained in:
TrèsAbhi committed 2024-10-12 23:43:06 -05:00
1 parent 9bc745bc0e
commit 4f5a8c9a37
5 files changed
+110 -12

No files matched your search

+9 -2
View File
@@ -1,12 +1,17 @@
import { Box, type BoxProps } from '@radix-ui/themes';
import { useEffect } from 'react';
import { useAdExempt } from '../hooks/useAdExempt';
type AdProps = BoxProps & {
export type AdProps = BoxProps & {
id: string;
};
export function Ad({ id, ...props }: AdProps) {
const exempt = useAdExempt();
useEffect(() => {
if (exempt) return;
(window as any).nitroAds.createAd(id, {
refreshTime: 30,
demo: import.meta.env.MODE === 'development',
@@ -19,7 +24,9 @@ export function Ad({ id, ...props }: AdProps) {
position: 'top-right',
},
});
}, []);
}, [exempt, id]);
if (exempt) return null;
return <Box id={id} width="100%" {...props} />;
}
@@ -0,0 +1,10 @@
import { App } from '../stores/app';
import { Ad, type AdProps } from './Ad';
export function AdWithContext(props: AdProps) {
return (
<App.Provider>
<Ad {...props} />
</App.Provider>
);
}