Skip to content

Commit a18368b

Browse files
committed
Hide ads to logged in users
1 parent d5029bb commit a18368b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/components/common/PostCardGrid.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { PartialPost } from '../../lib/graphql/post';
55
import { mediaQuery } from '../../lib/styles/media';
66
import AdFeed from './AdFeed';
77
import { detectAnyAdblocker } from 'just-detect-adblock';
8+
import useUser from '../../lib/hooks/useUser';
89

910
export type PostCardGridProps = {
1011
posts: PartialPost[];
@@ -14,6 +15,7 @@ export type PostCardGridProps = {
1415

1516
function PostCardGrid({ posts, loading, forHome }: PostCardGridProps) {
1617
const [adBlocked, setAdBlocked] = useState(false);
18+
const user = useUser();
1719

1820
useEffect(() => {
1921
detectAnyAdblocker().then((detected: boolean) => {
@@ -24,6 +26,7 @@ function PostCardGrid({ posts, loading, forHome }: PostCardGridProps) {
2426
}, []);
2527

2628
const postsWithAds = useMemo(() => {
29+
if (user) return posts; // hide ads to users
2730
if (adBlocked) return posts;
2831
if (!forHome) return posts;
2932
if (posts.length === 0) return posts;

0 commit comments

Comments
 (0)