feat: add label filter to issues and pulls list views
Add a label text input to the filter bar on both issues and pulls list views. The filter is passed through to the Gitea API's native labels query parameter for server-side filtering. Infinite scroll preserves the label filter across page loads. Closes leeworks-agents/gitea-mobile#82 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -325,7 +325,8 @@ type PaginatedPulls struct {
|
||||
|
||||
// ListAllIssues fetches issues across all repos in the given orgs,
|
||||
// using concurrent requests with a semaphore. Results are paginated.
|
||||
func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string, state string, page int) (PaginatedIssues, error) {
|
||||
// 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) {
|
||||
if state == "" {
|
||||
state = "open"
|
||||
}
|
||||
@@ -333,7 +334,7 @@ func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string,
|
||||
page = 1
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("issues-%s-%s", state, strings.Join(orgs, ","))
|
||||
cacheKey := fmt.Sprintf("issues-%s-%s-%s", state, strings.Join(orgs, ","), label)
|
||||
var allIssues []Issue
|
||||
if cached, ok := c.getFromCache(cacheKey); ok {
|
||||
allIssues = cached.([]Issue)
|
||||
@@ -362,6 +363,9 @@ func (c *Client) ListAllIssues(ctx context.Context, token string, orgs []string,
|
||||
defer func() { <-sem }()
|
||||
|
||||
path := fmt.Sprintf("/repos/%s/issues?state=%s&type=issues&limit=50", r.FullName, state)
|
||||
if label != "" {
|
||||
path += "&labels=" + label
|
||||
}
|
||||
resp, err := c.doRequest(ctx, token, http.MethodGet, path, nil)
|
||||
if err != nil {
|
||||
mu.Lock()
|
||||
@@ -424,8 +428,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.
|
||||
func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []string, state string, page int) (PaginatedPulls, error) {
|
||||
// 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) {
|
||||
if state == "" {
|
||||
state = "open"
|
||||
}
|
||||
@@ -433,7 +437,7 @@ func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []s
|
||||
page = 1
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("pulls-%s-%s", state, strings.Join(orgs, ","))
|
||||
cacheKey := fmt.Sprintf("pulls-%s-%s-%s", state, strings.Join(orgs, ","), label)
|
||||
var allPRs []PullRequest
|
||||
if cached, ok := c.getFromCache(cacheKey); ok {
|
||||
allPRs = cached.([]PullRequest)
|
||||
@@ -460,6 +464,9 @@ func (c *Client) ListAllPullRequests(ctx context.Context, token string, orgs []s
|
||||
defer func() { <-sem }()
|
||||
|
||||
path := fmt.Sprintf("/repos/%s/pulls?state=%s&limit=50", r.FullName, state)
|
||||
if label != "" {
|
||||
path += "&labels=" + label
|
||||
}
|
||||
resp, err := c.doRequest(ctx, token, http.MethodGet, path, nil)
|
||||
if err != nil {
|
||||
mu.Lock()
|
||||
@@ -524,7 +531,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)
|
||||
}
|
||||
@@ -537,7 +544,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