PageSourceSearch

https://4gameslist.com/assets/Forums-nYF_eXoA.js

js 4gameslist.com collected 2026-10-02 00:46:18 UTC 9,669 bytes, 1 lines download raw bytes

1import{r,j as e}from"./ui-lib-BwZZfEuU.js";import{u as ie,a as ce,s as i,b4 as oe,bq as Y,D as de,g as me,B as G,h as ue,i as ge,j as he,L as w,I as D,aU as xe,aV as pe,aW as fe,aX as ve,aY as X,G as Z,Z as je,b0 as be,R as ye,v as Ne,aC as _e,aa as we,a8 as Ce}from"./index-B6FiC5h9.js";import{u as Se}from"./react-vendor-CahocTIn.js";import{C as ke}from"./circle-plus-CfxjMpzd.js";import{m as Me}from"./animations-BNcyg-QM.js";import"./supabase-Bcbd4ikz.js";const z=20,Q=[{value:"general",label:"General"},{value:"gaming",label:"Gaming"},{value:"anime",label:"Anime & Manga"},{value:"movies",label:"Movies & TV"},{value:"tech",label:"Tech"},{value:"music",label:"Music"},{value:"help",label:"Help & Questions"},{value:"offtopic",label:"Off-topic"}];function Te(l){var d;return l.category==="custom"?l.custom_category||"Custom":((d=Q.find(C=>C.value===l.category))==null?void 0:d.label)||l.category}function g(l){return l?(l.startsWith("//")?`https:${l}`:l).replace("t_thumb","t_cover_big"):null}function Ae(){const[l,d]=r.useState([]),[C,F]=r.useState(!0),[E,L]=r.useState(!1),[J,K]=r.useState(!1),[ee,I]=r.useState(!1),[h,A]=r.useState(""),[m,R]=r.useState("general"),[S,U]=r.useState(""),[x,O]=r.useState(""),[p,k]=r.useState(""),[$,f]=r.useState([]),[v,M]=r.useState([]),[q,T]=r.useState(!1),{user:j}=ie(),{toast:u}=ce(),b=Se();r.useEffect(()=>{B(!0)},[]),r.useEffect(()=>{if(!p.trim()){f([]);return}const a=setTimeout(async()=>{const{data:t}=await i.from("igdb_games").select("id, name, cover_url").ilike("name",`%${p.trim()}%`).limit(8);f(t||[])},250);return()=>clearTimeout(a)},[p]);const ae=async a=>{const{data:t}=await i.from("forums").select("*").order("last_reply_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(a,a+z-1),s=t||[];if(s.length===0)return[];const o=[...new Set(s.map(n=>n.user_id))],{data:y}=await i.from("profiles").select("user_id, username, display_name, avatar_url, avatar_static_url, banner_url").in("user_id",o),N=new Map((y||[]).map(n=>[n.user_id,n])),ne=s.map(n=>n.id),_={},{data:H}=await i.from("forum_games").select("forum_id, game_id").in("forum_id",ne),P=[...new Set((H||[]).map(n=>n.game_id))];if(P.length>0){const{data:n}=await i.from("igdb_games").select("id, name, slug, cover_url").in("id",P),le=new Map((n||[]).map(c=>[c.id,c]));for(const c of H||[]){const W=le.get(c.game_id);W&&(_[c.forum_id]||(_[c.forum_id]=[]),_[c.forum_id].push(W))}}return s.map(n=>({...n,profile:N.get(n.user_id)||null,games:_[n.id]||[]}))},B=async a=>{a?F(!0):L(!0);const t=a?0:l.length,s=await ae(t);d(o=>a?s:[...o,...s]),K(s.length===z),F(!1),L(!1)},V=()=>{A(""),R("general"),U(""),O(""),k(""),f([]),M([])},se=a=>{M(t=>t.some(s=>s.id===a.id)?t:[...t,a]),k(""),f([])},te=a=>{M(t=>t.filter(s=>s.id!==a))},re=async()=>{if(!j){u({title:"Sign in required",description:"You need an account to create a forum."});return}if(!h.trim()||!x.trim())return;if(m==="custom"&&!S.trim()){u({title:"Category name required",variant:"destructive"});return}T(!0);const{data:a,error:t}=await i.from("forums").insert({user_id:j.id,title:h.trim(),content:x.trim(),category:m,custom_category:m==="custom"?S.trim():null}).select().single();if(t||!a){u({title:"Error",description:(t==null?void 0:t.message)||"Could not create forum",variant:"destructive"}),T(!1);return}v.length>0&&await i.from("forum_games").insert(v.map(s=>({forum_id:a.id,game_id:s.id}))),await i.from("forum_subscriptions").insert({forum_id:a.id,user_id:j.id}),u({title:"Forum created!"}),V(),I(!1),T(!1),b(`/forum/${a.id}`)};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(oe,{activeTab:"",onTabChange:a=>b(a==="home"?"/":`/?tab=${a}`)}),e.jsxs("main",{className:"container mx-auto px-4 py-8 max-w-5xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{className:"h-7 w-7 text-primary"}),e.jsx("h1",{className:"text-3xl font-bold",children:"Forum"})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Start discussions, link games and talk with the community."})]}),e.jsxs(de,{open:ee,onOpenChange:a=>{I(a),a||V()},children:[e.jsx(me,{asChild:!0,children:e.jsxs(G,{className:"bg-gradient-primary hover:shadow-glow gap-2 shrink-0",onClick:a=>{j||(a.preventDefault(),u({title:"Sign in required",description:"You need an account to create a forum."}),b("/auth"))},children:[e.jsx(ke,{className:"h-4 w-4"}),"Create forum"]})}),e.jsxs(ue,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsx(ge,{children:e.jsx(he,{children:"Create a Forum"})}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"Title"}),e.jsx(D,{value:h,onChange:a=>A(a.target.value),placeholder:"What do you want to talk about?",maxLength:120})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"Category"}),e.jsxs(xe,{value:m,onValueChange:R,children:[e.jsx(pe,{children:e.jsx(fe,{})}),e.jsxs(ve,{children:[Q.map(a=>e.jsx(X,{value:a.value,children:a.label},a.value)),e.jsx(X,{value:"custom",children:"Custom…"})]})]}),m==="custom"&&e.jsx(D,{value:S,onChange:a=>U(a.target.value),placeholder:"Custom category name...",maxLength:40})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"Link games (optional)"}),v.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(a=>e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border bg-muted/50 pl-1 pr-2 py-1 text-xs",children:[g(a.cover_url)?e.jsx("img",{src:g(a.cover_url),alt:"",className:"h-5 w-5 rounded-full object-cover"}):e.jsx(Z,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[140px] truncate",children:a.name}),e.jsx("button",{type:"button",onClick:()=>te(a.id),className:"text-muted-foreground hover:text-destructive",children:e.jsx(je,{className:"h-3 w-3"})})]},a.id))}),e.jsxs("div",{className:"relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{value:p,onChange:a=>k(a.target.value),placeholder:"Search games to attach...",className:"pl-10"}),$.length>0&&e.jsx("div",{className:"absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md overflow-hidden",children:$.map(a=>e.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-sm text-left hover:bg-muted",onClick:()=>se(a),children:[g(a.cover_url)?e.jsx("img",{src:g(a.cover_url),alt:"",className:"h-8 w-6 rounded object-cover shrink-0"}):e.jsx(Z,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate",children:a.name})]},a.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"Content"}),e.jsx(ye,{value:x,onChange:O,placeholder:"Start the discussion..."})]}),e.jsx(G,{onClick:re,disabled:q||!h.trim()||!x.trim(),className:"w-full",children:q?"Creating...":"Create Forum"})]})]})]})]}),C?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[1,2,3,4].map(a=>e.jsx("div",{className:"h-40 rounded-xl border bg-card animate-pulse"},a))}):l.length===0?e.jsxs("div",{className:"text-center py-20 text-muted-foreground",children:[e.jsx(Y,{className:"h-12 w-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{className:"text-lg",children:"No forums yet"}),e.jsx("p",{className:"text-sm",children:"Be the first to start a discussion."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:l.map((a,t)=>{var y,N;const s=a.profile,o=g((N=(y=a.games)==null?void 0:y[0])==null?void 0:N.cover_url)||(s==null?void 0:s.banner_url)||null;return e.jsxs(Me.button,{type:"button",initial:{opacity:0,y:12}
1,animate:{opacity:1,y:0},transition:{delay:Math.min(t,8)*.04},onClick:()=>b(`/forum/${a.id}`),className:"relative h-40 rounded-xl border bg-card overflow-hidden text-left group hover:border-primary/50 transition-colors",children:[o?e.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-transform duration-300 group-hover:scale-105",style:{backgroundImage:`url(${o})`}}):e.jsx("div",{className:"absolute inset-0 bg-gradient-primary opacity-30"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/85 via-black/55 to-black/30"}),e.jsxs("div",{className:"relative h-full flex flex-col justify-end p-4 gap-2",children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:e.jsx(Ne,{variant:"secondary",className:"bg-primary/20 text-primary-foreground border border-primary/30",children:Te(a)})}),e.jsx("h2",{className:"font-bold text-lg leading-tight text-white line-clamp-2",children:a.title}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-white/80 flex-wrap",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(_e,{avatarUrl:s==null?void 0:s.avatar_url,staticAvatarUrl:s==null?void 0:s.avatar_static_url,displayName:s==null?void 0:s.display_name,username:s==null?void 0:s.username,className:"h-5 w-5"}),e.jsx("span",{className:"truncate max-w-[120px]",children:(s==null?void 0:s.display_name)||(s==null?void 0:s.username)||"Unknown"})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{className:"h-3.5 w-3.5"}),a.replies_count||0]}),e.jsxs("span",{children:["last activity"," ",Ce(new Date(a.last_reply_at||a.created_at),{addSuffix:!0})]})]})]})]},a.id)})}),J&&e.jsx("div",{className:"flex justify-center mt-8",children:e.jsx(G,{variant:"outline",onClick:()=>B(!1),disabled:E,children:E?"Loading...":"Load more"})})]})]})]})}export{Q as FORUM_CATEGORIES,Ae as default,g as fixCoverUrl,Te as forumCategoryLabel};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.