1
Fork 0

Refactor more filterslice (gitea#30370)

This commit is contained in:
Lunny Xiao 2024-04-10 12:18:41 +08:00 committed by oliverpool
parent 525accfae6
commit 44abf6ab47
3 changed files with 13 additions and 23 deletions

View file

@ -197,14 +197,12 @@ func (nl NotificationList) LoadAttributes(ctx context.Context) error {
}
func (nl NotificationList) getPendingRepoIDs() []int64 {
ids := make(container.Set[int64], len(nl))
for _, notification := range nl {
if notification.Repository != nil {
continue
return container.FilterSlice(nl, func(n *Notification) (int64, bool) {
if n.Repository != nil {
return 0, false
}
ids.Add(notification.RepoID)
}
return ids.Values()
return n.RepoID, true
})
}
// LoadRepos loads repositories from database