1import{r as a}from"./vendor-react-DTP8y_xJ.js";import{b as m,s as u}from"./index-tQjrzw8f.js";const l=()=>{const[d,i]=a.useState({}),{user:t}=m(),o=a.useCallback(async()=>{if(t)try{const{data:e}=await u.from("projects").select("id"),s=(e==null?void 0:e.map(r=>r.id))||[];if(s.length===0){i({});return}const{data:c}=await u.from("messages").select("project_id").in("project_id",s).neq("user_id",t.id).not("read_by","cs",`{${t.id}}`),n={};s.forEach(r=>n[r]=0),c==null||c.forEach(r=>{n[r.project_id]=(n[r.project_id]||0)+1}),i(n)}catch(e){console.error("Error fetching unread counts:",e)}},[t]);return a.useEffect(()=>{o()},[o]),a.useEffect(()=>{if(!t)return;let e;const s=()=>{clearTimeout(e),e=setTimeout(o,300)},c=u.channel("unread-messages-optimized").on("postgres_changes",{event:"INSERT",schema:"public",table:"messages"},s).on("postgres_changes",{event:"UPDATE",schema:"public",table:"messages"},s).subscribe();return()=>{clearTimeout(e),u.removeChannel(c)}},[t,o]),{unreadCounts:d,refetch:o}};export{l as u};
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.