MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / useIssues

Function useIssues

ui/src/hooks/useIssues.ts:32–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 * a consumer mounts.
31 */
32export function useIssues(): UseIssues {
33 const [data, setData] = useState<IssueSnapshot | null>(cached)
34 const [error, setError] = useState<string | null>(null)
35 const mounted = useRef(true)
36
37 useEffect(() => {
38 mounted.current = true
39 const load = async () => {
40 try {
41 const next = await api.issues.get()
42 cached = next
43 if (mounted.current) {
44 setData(next)
45 setError(null)
46 }
47 } catch (e) {
48 if (mounted.current) setError(e instanceof Error ? e.message : String(e))
49 }
50 }
51 void load()
52 const id = setInterval(() => void load(), POLL_MS)
53 return () => {
54 mounted.current = false
55 clearInterval(id)
56 }
57 }, [])
58
59 return { data, error, loading: data === null && error === null }
60}

Callers 3

IssuesBoardFunction · 0.90
IssueDetailFunction · 0.90
DetailFunction · 0.90

Calls 1

loadFunction · 0.70

Tested by

no test coverage detected