Skip to content

Commit eaab29d

Browse files
committed
fix: select repo
1 parent c2dcab2 commit eaab29d

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

routers/web/user/home.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,14 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
457457
if team != nil {
458458
repoOpts.TeamID = team.ID
459459
}
460+
accessibleRepos := container.Set[int64]{}
460461
{
461462
ids, _, err := repo_model.SearchRepositoryIDs(repoOpts)
462463
if err != nil {
463464
ctx.ServerError("SearchRepositoryIDs", err)
464465
return
465466
}
467+
accessibleRepos.AddMultiple(ids...)
466468
opts.RepoIDs = ids
467469
if len(opts.RepoIDs) == 0 {
468470
// no repos found, don't let the indexer return all repos
@@ -489,18 +491,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
489491
keyword := strings.Trim(ctx.FormString("q"), " ")
490492
ctx.Data["Keyword"] = keyword
491493

492-
accessibleRepos := container.Set[int64]{}
493-
{
494-
ids, err := issues_model.GetRepoIDsForIssuesOptions(opts, ctxUser)
495-
if err != nil {
496-
ctx.ServerError("GetRepoIDsForIssuesOptions", err)
497-
return
498-
}
499-
for _, id := range ids {
500-
accessibleRepos.Add(id)
501-
}
502-
}
503-
504494
// Educated guess: Do or don't show closed issues.
505495
isShowClosed := ctx.FormString("state") == "closed"
506496
opts.IsClosed = util.OptionalBoolOf(isShowClosed)
@@ -539,13 +529,13 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
539529

540530
// Parse ctx.FormString("repos") and remember matched repo IDs for later.
541531
// Gets set when clicking filters on the issues overview page.
542-
repoIDs := getRepoIDs(ctx.FormString("repos"))
543-
if len(repoIDs) > 0 {
532+
selectedRepoIDs := getRepoIDs(ctx.FormString("repos"))
533+
if len(selectedRepoIDs) > 0 {
544534
// Remove repo IDs that are not accessible to the user.
545-
repoIDs = util.SliceRemoveAllFunc(repoIDs, func(v int64) bool {
535+
selectedRepoIDs = util.SliceRemoveAllFunc(selectedRepoIDs, func(v int64) bool {
546536
return !accessibleRepos.Contains(v)
547537
})
548-
opts.RepoIDs = repoIDs
538+
opts.RepoIDs = selectedRepoIDs
549539
}
550540

551541
// ------------------------------
@@ -676,7 +666,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
676666
ctx.Data["IssueStats"] = issueStats
677667
ctx.Data["ViewType"] = viewType
678668
ctx.Data["SortType"] = sortType
679-
ctx.Data["RepoIDs"] = opts.RepoIDs
669+
ctx.Data["RepoIDs"] = selectedRepoIDs
680670
ctx.Data["IsShowClosed"] = isShowClosed
681671
ctx.Data["SelectLabels"] = selectedLabels
682672

0 commit comments

Comments
 (0)