diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-10-12 07:18:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-12 13:18:26 +0800 |
commit | 0e57ff7eee4ac71d923f970d15889ad4d50f97a9 (patch) | |
tree | e5a92c55af5366924bd40ae14b4bf12842239193 /models/issues/reaction.go | |
parent | e84558b0931309cf1f4f2767bc47296483b9b3e1 (diff) | |
download | gitea-0e57ff7eee4ac71d923f970d15889ad4d50f97a9.tar.gz gitea-0e57ff7eee4ac71d923f970d15889ad4d50f97a9.zip |
Add generic set type (#21408)
This PR adds a generic set type to get rid of maps used as sets.
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'models/issues/reaction.go')
-rw-r--r-- | models/issues/reaction.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/models/issues/reaction.go b/models/issues/reaction.go index e7295c8af8..ccda10be2c 100644 --- a/models/issues/reaction.go +++ b/models/issues/reaction.go @@ -211,7 +211,7 @@ type ReactionOptions struct { // CreateReaction creates reaction for issue or comment. func CreateReaction(opts *ReactionOptions) (*Reaction, error) { - if !setting.UI.ReactionsMap[opts.Type] { + if !setting.UI.ReactionsLookup.Contains(opts.Type) { return nil, ErrForbiddenIssueReaction{opts.Type} } @@ -316,16 +316,14 @@ func (list ReactionList) GroupByType() map[string]ReactionList { } func (list ReactionList) getUserIDs() []int64 { - userIDs := make(map[int64]struct{}, len(list)) + userIDs := make(container.Set[int64], len(list)) for _, reaction := range list { if reaction.OriginalAuthor != "" { continue } - if _, ok := userIDs[reaction.UserID]; !ok { - userIDs[reaction.UserID] = struct{}{} - } + userIDs.Add(reaction.UserID) } - return container.KeysInt64(userIDs) + return userIDs.Values() } func valuesUser(m map[int64]*user_model.User) []*user_model.User { |