Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Nov 7, 2019
1 parent 2d8a320 commit 84203b0
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions models/issue_assignees.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package models

import (
"code.gitea.io/gitea/modules/util"
"fmt"

"xorm.io/xorm"
Expand Down Expand Up @@ -173,24 +174,21 @@ func MakeIDsFromAPIAssigneesToAdd(oneAssignee string, multipleAssignees []string

var requestAssignees []string

// Prevent double adding assignees and empty assignees
var isDouble bool
for _, assignee := range multipleAssignees {
// Keeping the old assigning method for compatibility reasons
if assignee == oneAssignee {
isDouble = true
continue
}

//if assignee is empty skip
if assignee == "" {
continue
}
requestAssignees = append(requestAssignees, assignee)
// Keeping the old assigning method for compatibility reasons
if !util.ExistsInSlice(oneAssignee, multipleAssignees) {
requestAssignees = append(requestAssignees, oneAssignee)
}

if !isDouble {
requestAssignees = append(requestAssignees, oneAssignee)
//Prevent empty assignerees
if util.ExistsInSlice("", multipleAssignees) {
for _, assignee := range multipleAssignees {
if assignee == "" {
continue
}
requestAssignees = append(requestAssignees, assignee)
}
} else {
requestAssignees = append(requestAssignees, multipleAssignees...)
}

if len(requestAssignees) > 0 {
Expand Down

0 comments on commit 84203b0

Please sign in to comment.