From 476431bcb155f1cafc6b5b90323825cbca0d63f7 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 20 Apr 2016 17:47:40 -0700 Subject: [PATCH] fix(message): Re-write nasty code in participants() --- src/flux/models/message.coffee | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/flux/models/message.coffee b/src/flux/models/message.coffee index 0866f5737..6ffaffb05 100644 --- a/src/flux/models/message.coffee +++ b/src/flux/models/message.coffee @@ -222,12 +222,15 @@ class Message extends ModelWithMetadata # Public: Returns a set of uniqued message participants by combining the # `to`, `cc`, and `from` fields. participants: -> - participants = {} - contacts = _.union((@to ? []), (@cc ? []), (@from ? [])) - for contact in contacts - if contact? and contact.email?.length > 0 - participants["#{(contact?.email ? "").toLowerCase().trim()} #{(contact?.name ? "").toLowerCase().trim()}"] = contact if contact? - return _.values(participants) + seen = {} + all = [] + for contact in [].concat(@to, @cc, @from) + continue unless contact.email + key = contact.toString().trim().toLowerCase() + continue if seen[key] + seen[key] = true + all.push(contact) + all # Public: Returns a hash with `to` and `cc` keys for authoring a new draft in # "reply all" to this message. This method takes into account whether the