Skip to content

Commit 6f86f49

Browse files
committed
add sugestions
1 parent ccc6316 commit 6f86f49

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

routers/user/home.go

+17-26
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ func Issues(ctx *context.Context) {
285285
}
286286
opts.LabelIDs = labelIDs
287287

288-
if len(repoIDs) > 0 {
289-
opts.RepoIDs = repoIDs
290-
}
288+
opts.RepoIDs = repoIDs
291289

292290
issues, err := models.Issues(opts)
293291
if err != nil {
@@ -297,30 +295,23 @@ func Issues(ctx *context.Context) {
297295

298296
showReposMap := make(map[int64]*models.Repository, len(counts))
299297
for repoID := range counts {
300-
if repoID > 0 {
301-
if _, ok := showReposMap[repoID]; !ok {
302-
repo, err := models.GetRepositoryByID(repoID)
303-
if models.IsErrRepoNotExist(err) {
304-
ctx.NotFound("GetRepositoryByID", err)
305-
return
306-
} else if err != nil {
307-
ctx.ServerError("GetRepositoryByID", fmt.Errorf("[%d]%v", repoID, err))
308-
return
309-
}
310-
showReposMap[repoID] = repo
311-
}
312-
313-
repo := showReposMap[repoID]
298+
showReposMap[repoID], err = models.GetRepositoryByID(repoID)
299+
if models.IsErrRepoNotExist(err) {
300+
ctx.NotFound("GetRepositoryByID", err)
301+
return
302+
} else if err != nil {
303+
ctx.ServerError("GetRepositoryByID", fmt.Errorf("[%d]%v", repoID, err))
304+
return
305+
}
314306

315-
// Check if user has access to given repository.
316-
perm, err := models.GetUserRepoPermission(repo, ctxUser)
317-
if err != nil {
318-
ctx.ServerError("GetUserRepoPermission", fmt.Errorf("[%d]%v", repoID, err))
319-
return
320-
}
321-
if !perm.CanRead(models.UnitTypeIssues) {
322-
log.Error("User created Issues in Repository which they no longer have access to: [%d]", repoID)
323-
}
307+
// Check if user has access to given repository.
308+
perm, err := models.GetUserRepoPermission(showReposMap[repoID], ctxUser)
309+
if err != nil {
310+
ctx.ServerError("GetUserRepoPermission", fmt.Errorf("[%d]%v", repoID, err))
311+
return
312+
}
313+
if !perm.CanRead(models.UnitTypeIssues) {
314+
log.Error("User created Issues in Repository which they no longer have access to: [%d]", repoID)
324315
}
325316
}
326317

templates/user/dashboard/issues.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="ui stackable grid">
66
<div class="four wide column">
77
<div class="ui secondary vertical filter menu">
8-
<a class="{{if eq .ViewType "your_repositories"}}ui basic blue button{{end}} item" href="{{.Link}}?type=your_repositories&repos=[]&sort={{$.SortType}}&state={{.State}}">
8+
<a class="{{if eq .ViewType "your_repositories"}}ui basic blue button{{end}} item" href="{{.Link}}?type=your_repositories&repos=[{{range $.RepoIDs}}{{.}}%2C{{end}}]&sort={{$.SortType}}&state={{.State}}">
99
{{.i18n.Tr "home.issues.in_your_repos"}}
1010
<strong class="ui right">{{.IssueStats.YourRepositoriesCount}}</strong>
1111
</a>

0 commit comments

Comments
 (0)