Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

usePulls.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

usePulls.tsBlame56 lines · 1 contributor
c53cf00Claude1import { useState, useEffect, useCallback } from 'react';
2import { api, type PullRequest, type PullComment } from '../api/client';
3
4export function usePulls(owner: string | null, repo: string | null, state: 'open' | 'closed' | 'merged' | 'all' = 'open') {
5 const [pulls, setPulls] = useState<PullRequest[]>([]);
6 const [loading, setLoading] = useState(false);
7 const [error, setError] = useState<string | null>(null);
8
9 const fetch = useCallback(async () => {
10 if (!owner || !repo) return;
11 setLoading(true);
12 setError(null);
13 try {
14 const data = await api.listPulls(owner, repo, state);
15 setPulls(data);
16 } catch (err) {
17 setError(err instanceof Error ? err.message : 'Failed to load pull requests');
18 } finally {
19 setLoading(false);
20 }
21 }, [owner, repo, state]);
22
23 useEffect(() => {
24 fetch();
25 }, [fetch]);
26
27 return { pulls, loading, error, refresh: fetch };
28}
29
30export function usePull(owner: string | null, repo: string | null, number: number | null) {
31 const [pull, setPull] = useState<PullRequest | null>(null);
32 const [comments, setComments] = useState<PullComment[]>([]);
33 const [loading, setLoading] = useState(false);
34 const [error, setError] = useState<string | null>(null);
35
36 const fetch = useCallback(async () => {
37 if (!owner || !repo || number === null) return;
38 setLoading(true);
39 setError(null);
40 try {
41 const data = await api.getPull(owner, repo, number);
42 setPull(data.pull);
43 setComments(data.comments);
44 } catch (err) {
45 setError(err instanceof Error ? err.message : 'Failed to load pull request');
46 } finally {
47 setLoading(false);
48 }
49 }, [owner, repo, number]);
50
51 useEffect(() => {
52 fetch();
53 }, [fetch]);
54
55 return { pull, comments, loading, error, refresh: fetch };
56}