feat: add repo-level filter to issues and pulls list views
Add a repo dropdown to the filter bar that appears when an org is selected. The dropdown lists all repos in the selected org and filters issues/pulls to the chosen repo. Changing the org resets the repo filter. Infinite scroll preserves the repo filter. Closes leeworks-agents/gitea-mobile#83 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -326,7 +326,8 @@ type PaginatedPulls struct {
|
||||
// ListAllIssues fetches issues across all repos in the given orgs,
|
||||
// using concurrent requests with a semaphore. Results are paginated.
|
||||
// The label parameter filters issues by label name (empty string means no filter).
|
||||
func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string, state string, page int, label string) (PaginatedIssues, error) {
|
||||
// The repoFilter parameter narrows results to a single repo name (empty means all repos).
|
||||
func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string, state string, page int, label string, repoFilter string) (PaginatedIssues, error) {
|
||||
if state == "" {
|
||||
state = "open"
|
||||
}
|
||||
@@ -334,7 +335,7 @@ func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string,
|
||||
page = 1
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("issues-%s-%s-%s", state, strings.Join(orgs, ","), label)
|
||||
cacheKey := fmt.Sprintf("issues-%s-%s-%s-%s", state, strings.Join(orgs, ","), label, repoFilter)
|
||||
var allIssues []Issue
|
||||
if cached, ok := c.getFromCache(cacheKey); ok {
|
||||
allIssues = cached.([]Issue)
|
||||
@@ -349,6 +350,17 @@ func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string,
|
||||
allRepos = append(allRepos, repos...)
|
||||
}
|
||||
|
||||
// Filter to a single repo if specified.
|
||||
if repoFilter != "" {
|
||||
var filtered []Repo
|
||||
for _, r := range allRepos {
|
||||
if r.Name == repoFilter {
|
||||
filtered = append(filtered, r)
|
||||
}
|
||||
}
|
||||
allRepos = filtered
|
||||
}
|
||||
|
||||
// Fan out issue fetching across repos.
|
||||
var mu sync.Mutex
|
||||
sem := make(chan struct{}, c.maxConcurrent)
|
||||
@@ -429,7 +441,8 @@ func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string,
|
||||
|
||||
// ListAllPullRequests fetches PRs across all repos in the given orgs.
|
||||
// Results are paginated. The label parameter filters PRs by label name.
|
||||
func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []string, state string, page int, label string) (PaginatedPulls, error) {
|
||||
// The repoFilter parameter narrows results to a single repo name.
|
||||
func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []string, state string, page int, label string, repoFilter string) (PaginatedPulls, error) {
|
||||
if state == "" {
|
||||
state = "open"
|
||||
}
|
||||
@@ -437,7 +450,7 @@ func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []s
|
||||
page = 1
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("pulls-%s-%s-%s", state, strings.Join(orgs, ","), label)
|
||||
cacheKey := fmt.Sprintf("pulls-%s-%s-%s-%s", state, strings.Join(orgs, ","), label, repoFilter)
|
||||
var allPRs []PullRequest
|
||||
if cached, ok := c.getFromCache(cacheKey); ok {
|
||||
allPRs = cached.([]PullRequest)
|
||||
@@ -451,6 +464,17 @@ func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []s
|
||||
allRepos = append(allRepos, repos...)
|
||||
}
|
||||
|
||||
// Filter to a single repo if specified.
|
||||
if repoFilter != "" {
|
||||
var filtered []Repo
|
||||
for _, r := range allRepos {
|
||||
if r.Name == repoFilter {
|
||||
filtered = append(filtered, r)
|
||||
}
|
||||
}
|
||||
allRepos = filtered
|
||||
}
|
||||
|
||||
var mu sync.Mutex
|
||||
sem := make(chan struct{}, c.maxConcurrent)
|
||||
var wg sync.WaitGroup
|
||||
@@ -531,7 +555,7 @@ func (c *Client) GetTriageQueue(ctx context.Context, token string, orgs []string
|
||||
// Collect all open issues across all pages.
|
||||
var issues []Issue
|
||||
for page := 1; ; page++ {
|
||||
result, err := c.ListAllIssues(ctx, token, orgs, "open", page, "")
|
||||
result, err := c.ListAllIssues(ctx, token, orgs, "open", page, "", "")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fetching issues for triage: %w", err)
|
||||
}
|
||||
@@ -544,7 +568,7 @@ func (c *Client) GetTriageQueue(ctx context.Context, token string, orgs []string
|
||||
// Collect all open PRs across all pages.
|
||||
var prs []PullRequest
|
||||
for page := 1; ; page++ {
|
||||
result, err := c.ListAllPullRequests(ctx, token, orgs, "open", page, "")
|
||||
result, err := c.ListAllPullRequests(ctx, token, orgs, "open", page, "", "")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fetching PRs for triage: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user