From 84203b05ffba3285ab7aaec866dcd2e696fe29b1 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 7 Nov 2019 20:13:43 +0100 Subject: [PATCH] simplify --- models/issue_assignees.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/models/issue_assignees.go b/models/issue_assignees.go index 150740df590dc..ec6aea5566eac 100644 --- a/models/issue_assignees.go +++ b/models/issue_assignees.go @@ -5,6 +5,7 @@ package models import ( + "code.gitea.io/gitea/modules/util" "fmt" "xorm.io/xorm" @@ -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 {