diff --git a/app/api/galleries/[id]/thumbnail/route.ts b/app/api/galleries/[id]/thumbnail/route.ts index 0a45b10..ffc181c 100644 --- a/app/api/galleries/[id]/thumbnail/route.ts +++ b/app/api/galleries/[id]/thumbnail/route.ts @@ -20,7 +20,9 @@ export async function GET( const galleryId = params.id.toLowerCase().replace(/\s+/g, '_'); const supabase = createClient(); const user = await supabase.auth.getUser(); - + const url = new URL(request.url); + const search = url.searchParams.get("nsfw"); + const nsfw = search === "true"; const { data: gallery, error: galleryError } = await supabase .from('galleries') @@ -49,7 +51,7 @@ export async function GET( .select('*') .eq('user_id', userId) .single(); - if(gallery.nsfw){ + if(nsfw && gallery.nsfw){ blobBuffer = await blurImage(blobBuffer); } const contentType = files[0].name.endsWith('.png') ? 'image/png' : 'image/jpeg'; diff --git a/app/gallery/page.tsx b/app/gallery/page.tsx index 541f2e1..f266261 100644 --- a/app/gallery/page.tsx +++ b/app/gallery/page.tsx @@ -12,6 +12,7 @@ function PageComponent() { const supabase = createClient(); + const [showNSFW, setShowNSFW] = useState(true); const [randomIds, setRandomIds] = useState([]); // replace any with your gallery type const [isOpen, setIsOpen] = useState(false); const [galleries, setGalleries] = useState([]); // replace any with your gallery type @@ -47,7 +48,7 @@ function PageComponent() { const getData = async () => { let { data: { user } } = await supabase.auth.getUser(); - const galleriesResponse = await fetch(`/api/galleries?search=`+search, { + const galleriesResponse = await fetch(`/api/galleries?search=`+search+'&nsfw='+showNSFW, { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -66,7 +67,7 @@ function PageComponent() { useEffect(() => { getData(); - }, [selectedTags,search]); + }, [selectedTags,search,showNSFW]); const handleTagClick = (tag: number) => { if (selectedTags.includes(tag)) { @@ -89,16 +90,28 @@ function PageComponent() {
{(tags.length>0) ? (
- - setSearch(e.target.value)} - style={{ - animation: 'expandFromLeft 2s ease-out forwards' - }} - /> +
+ setSearch(e.target.value)} + style={{ + animation: 'expandFromLeft 2s ease-out forwards', + paddingRight: '2rem', // make room for the checkbox + }} + /> + +
{(tags.length>0) ? (